From 20e8520c441d1335f934b4ec60fd2808588bc4a6 Mon Sep 17 00:00:00 2001 From: Itai Nelken <70802936+Itai-Nelken@users.noreply.github.com> Date: Thu, 4 Feb 2021 23:47:49 +0200 Subject: [PATCH 1/5] etcher download latest version automatically --- apps/etcher.sh | 58 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/apps/etcher.sh b/apps/etcher.sh index 6108085..4fc88c4 100644 --- a/apps/etcher.sh +++ b/apps/etcher.sh @@ -4,6 +4,24 @@ function error { echo -e "\e[91m$1\e[39m" } +function download_latest_release_armhf() { + echo "Downloading latest armhf release..." + curl -s https://api.github.com/repos/$1/releases/latest \ + | grep "browser_download_url.*armv7l.deb" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | wget -qi - +} + +function download_latest_release_arm64() { + echo "Downloading latest arm64 release..." + curl -s https://api.github.com/repos/$1/releases/latest \ + | grep "browser_download_url.*armv64.deb" \ + | cut -d : -f 2,3 \ + | tr -d \" \ + | wget -qi - +} + #variables DIRECTORY="$HOME/Pi-Assistant" APPS="$HOME/Pi-Assistant/apps" @@ -20,26 +38,44 @@ do "install") sudo apt update || error "Failed to update repos (not critical)." -if $(uname -m | grep '64'); then - wget https://github.com/Itai-Nelken/Etcher-arm-32-64/releases/download/realease/balena-etcher-electron_1.5.110+1f8f7ad7_arm64.deb -O ~/etcher64.deb || error "Failed to download!" - - sudo apt install -y --fix-broken ~/etcher64.deb || error "failed to install deb file!" - rm -f ~/etcher64.deb +#determine if host system is 64 bit arm64 or 32 bit armhf +if [ ! -z "$(file "$(readlink -f "/sbin/init")" | grep 64)" ];then +echo "Installing arm64 etcher..." + cd $HOME || error "Failed to change to home directory (not super critical)" + download_latest_release_arm64 Itai-Nelken/Etcher-arm-32-64 || error "Failed to Download etcher!"; read -p "press enter to exit"; exit 1 + sudo apt -f -y install ./balena-etcher-electron*arm64.deb || error "Failed to install etcher deb!"; read -p "press enter to exit"; exit 1 + rm -f balena-etcher-electron*arm64.deb || error "Failed to delete etcher deb (not critical)" +elif [ ! -z "$(file "$(readlink -f "/sbin/init")" | grep 32)" ];then + echo "Installing armhf etcher..." + cd $HOME || error "Failed to change to home directory (not super critical)" + download_latest_release_armhf Itai-Nelken/Etcher-arm-32-64 || error "Failed to Download etcher!"; read -p "press enter to exit"; exit 1 + sudo apt -f -y ./install balena-etcher-electron*armv7l.deb || error "Failed to install etcher deb!"; read -p "press enter to exit"; exit 1 + rm -f balena-etcher-electron*armv7l.deb || error "Failed to delete etcher deb (not critical)" else - wget https://github.com/Itai-Nelken/Etcher-arm-32-64/releases/download/realease/balena-etcher-electron_1.5.110+1f8f7ad7_armv7l.deb -O ~/etcher32.deb || error "Failed to download!" - - sudo apt install -y --fix-broken ~/etcher32.deb || error "failed to install deb file!" - rm -f ~/etcher32.deb - + error "Failed to detect OS CPU architecture! Something is very wrong." fi +#if $(uname -m | grep '64'); then +# +# wget https://github.com/Itai-Nelken/Etcher-arm-32-64/releases/download/realease/balena-etcher-electron_1.5.110+1f8f7ad7_arm64.deb -O ~/etcher64.deb || error "Failed to download!" +# +# sudo apt install -y --fix-broken ~/etcher64.deb || error "failed to install deb file!" +# rm -f ~/etcher64.deb +#else +# wget https://github.com/Itai-Nelken/Etcher-arm-32-64/releases/download/realease/balena-etcher-electron_1.5.110+1f8f7ad7_armv7l.deb -O ~/etcher32.deb || error "Failed to download!" +# +# sudo apt install -y --fix-broken ~/etcher32.deb || error "failed to install deb file!" + # rm -f ~/etcher32.deb +# +#fi + break ;; "compile") -wget -qO- https://raw.githubusercontent.com/Itai-Nelken/Etcher-arm-32-64/main/compile-etcher_v1.5.113.sh | bash || error "Failed to download and run compile sctipt!" +wget -qO- https://raw.githubusercontent.com/Itai-Nelken/Etcher-arm-32-64/main/compile-etcher_v1.5.116.sh | bash || error "Failed to download and run compile sctipt!" read -p "do you want to install etcher from the deb you just compiled (y/n)?" choice case "$choice" in y|Y ) echo "installing etcher..." && cd $HOME/Downloads/etcher/dist && sudo apt install -y --fix-missing balena-etcher-electron*.deb;; From 4ae22888125b06e32df3561bee14fd61399641f7 Mon Sep 17 00:00:00 2001 From: Itai Nelken <70802936+Itai-Nelken@users.noreply.github.com> Date: Fri, 5 Feb 2021 10:24:55 +0200 Subject: [PATCH 2/5] updater make all executable and refresh shortcuts only when updating this means faster startup times. --- updater.sh | 153 ++++++++++++++++++++++++++++------------------------- 1 file changed, 81 insertions(+), 72 deletions(-) diff --git a/updater.sh b/updater.sh index 12173fe..bf4ed4e 100644 --- a/updater.sh +++ b/updater.sh @@ -1,6 +1,6 @@ #!/bin/bash -function error { +function error() { echo -e "\e[91m$1\e[39m" } @@ -8,7 +8,7 @@ DIRECTORY="$HOME/Pi-Assistant" APPS="$HOME/Pi-Assistant/apps" #update function -function update { +function update)() { echo "Checking for updates..." cd $DIRECTORY localhash="$(git rev-parse HEAD)" @@ -18,13 +18,15 @@ function update { git clean -fd git reset --hard git pull https://github.com/Itai-Nelken/Pi-Assistant.git HEAD || error 'Unable to update, please check your internet connection' + make-all-executable + refresh-shortcuts else echo "Up to date." fi } #update function with no extra output -function update-no-output { +function update-no-output() { cd $DIRECTORY localhash="$(git rev-parse HEAD)" latesthash="$(git ls-remote https://github.com/Itai-Nelken/Pi-Assistant HEAD | awk '{print $1}')" @@ -32,6 +34,8 @@ function update-no-output { git clean -fd git reset --hard git pull https://github.com/Itai-Nelken/Pi-Assistant.git HEAD || error 'Unable to update, please check your internet connection' + make-all-executable + refresh-shortcuts else clear #print a "loading screen" @@ -40,79 +44,84 @@ function update-no-output { } -if [[ $1 = "--no-output" ]]; then - update-no-output -else - update -fi +function make-all-executable() { + sudo chmod +x main.sh + sudo chmod +x passwd.sh + sudo chmod +x systools.sh + sudo chmod +x other.sh + sudo chmod +x install.sh + sudo chmod +x update.sh + sudo chmod +x updater.sh + sudo chmod +x uninstall.sh + sudo chmod +x sys-info.sh + sudo chmod +x apps/appinstaller.sh + sudo chmod +x apps/gparted.sh + sudo chmod +x apps/chromium.sh + sudo chmod +x apps/firefox.sh + sudo chmod +x apps/blender.sh + sudo chmod +x apps/audacity.sh + sudo chmod +x apps/inkscape.sh + sudo chmod +x apps/snap.sh + sudo chmod +x apps/SSR.sh + sudo chmod +x apps/kdenlive.sh + sudo chmod +x apps/gsysmon.sh + sudo chmod +x apps/flatpak.sh + sudo chmod +x apps/etcher.sh + sudo chmod +x apps/zoom.sh + sudo chmod +x apps/box86.sh +} + +function refresh-shortcuts() { + rm ~/.local/share/applications/piassist.desktop + rm ~/Desktop/piassist.desktop -sudo chmod +x main.sh -sudo chmod +x passwd.sh -sudo chmod +x systools.sh -sudo chmod +x other.sh -sudo chmod +x install.sh -sudo chmod +x update.sh -sudo chmod +x updater.sh -sudo chmod +x uninstall.sh -sudo chmod +x sys-info.sh -sudo chmod +x apps/appinstaller.sh -sudo chmod +x apps/gparted.sh -sudo chmod +x apps/chromium.sh -sudo chmod +x apps/firefox.sh -sudo chmod +x apps/blender.sh -sudo chmod +x apps/audacity.sh -sudo chmod +x apps/inkscape.sh -sudo chmod +x apps/snap.sh -sudo chmod +x apps/SSR.sh -sudo chmod +x apps/kdenlive.sh -sudo chmod +x apps/gsysmon.sh -sudo chmod +x apps/flatpak.sh -sudo chmod +x apps/etcher.sh -sudo chmod +x apps/zoom.sh -sudo chmod +x apps/box86.sh + #update menu shortcut + echo "[Desktop Entry] + StartupNotify=true + Terminal=true + Type=Application + Name=Pi-Assistant + Exec="$HOME/Pi-Assistant/main.sh" + Icon="$HOME/Pi-Assistant/icons/64x64/logo-64.png" + Categories=Utility; + Comment="Pi-Assistant v1.2.1"" > ~/.local/share/applications/piassist.desktop + cp ~/.local/share/applications/piassist.desktop ~/Desktop/piassist.desktop + sudo chmod +x ~/Desktop/piassist.desktop + + sudo rm /usr/local/bin/piassist + #update startup from terminal using 'piassist' + echo '#!/bin/bash + cd ~/Pi-Assistant + #flags + if [[ $1 = "--version" ]]; then + echo -e "$(tput bold)$(tput setaf 4)Pi-Assistant\nv1.2.1\nby Itai Nelken$(tput sgr 0)" + exit + elif [[ $1 = "--secret" ]]; then + xdg-open ~/Pi-Assistant/icons/ascii-art.html + sleep 10 + clear + read -p "press [ENTER] to exit" + exit + elif [[ $1 = "--no-internet" ]]; then + ./main.sh --no-internet + elif [[ $1 = "--help" ]]; then + ./main.sh --help + elif [[ $1 = "--no-update" ]]; then + ./main.sh --no-update + else + clear && $HOME/Pi-Assistant/main.sh + fi' > ~/Downloads/piassist + sudo mv ~/Downloads/piassist /usr/local/bin/ + sudo chmod +x /usr/local/bin/piassist +} -rm ~/.local/share/applications/piassist.desktop -rm ~/Desktop/piassist.desktop -#update menu shortcut -echo "[Desktop Entry] -StartupNotify=true -Terminal=true -Type=Application -Name=Pi-Assistant -Exec="$HOME/Pi-Assistant/main.sh" -Icon="$HOME/Pi-Assistant/icons/64x64/logo-64.png" -Categories=Utility; -Comment="Pi-Assistant v1.2.1"" > ~/.local/share/applications/piassist.desktop -cp ~/.local/share/applications/piassist.desktop ~/Desktop/piassist.desktop -sudo chmod +x ~/Desktop/piassist.desktop -sudo rm /usr/local/bin/piassist -#update startup from terminal using 'piassist' -echo '#!/bin/bash -cd ~/Pi-Assistant -#flags -if [[ $1 = "--version" ]]; then - clear - echo -e "$(tput bold)$(tput setaf 4)Pi-Assistant\nv1.2.1\nby Itai Nelken$(tput sgr 0)" - read -p "press [ENTER] to exit..." - exit -elif [[ $1 = "--secret" ]]; then - xdg-open ~/Pi-Assistant/icons/ascii-art.html - sleep 10 - clear - read -p "press [ENTER] to exit" - exit -elif [[ $1 = "--no-internet" ]]; then - ./main.sh --no-internet -elif [[ $1 = "--help" ]]; then - ./main.sh --help -elif [[ $1 = "--no-update" ]]; then - ./main.sh --no-update +if [[ "$1" == "--no-output" ]]; then + update-no-output else - clear && $HOME/Pi-Assistant/main.sh -fi' > ~/Downloads/piassist -sudo mv ~/Downloads/piassist /usr/local/bin/ -sudo chmod +x /usr/local/bin/piassist + update +fi + #echo "$(tput setaf 3)finished...$(tput sgr 0)" From a4af6966ec4de6dd6f687597edab6b8e11d8c394 Mon Sep 17 00:00:00 2001 From: Itai Nelken <70802936+Itai-Nelken@users.noreply.github.com> Date: Fri, 5 Feb 2021 15:17:29 +0200 Subject: [PATCH 3/5] show loading... after flags --- main.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.sh b/main.sh index 7fd8f96..efe406e 100755 --- a/main.sh +++ b/main.sh @@ -28,9 +28,6 @@ fi DIRECTORY="$HOME/Pi-Assistant" APPS="$HOME/Pi-Assistant/apps" -#print a "loading screen" -echo "$(tput setaf 2)$(tput bold)LOADING...$(tput sgr 0)" - #flags if [[ $1 = "--version" ]]; then echo -e "$(tput bold)$(tput setaf 4)Pi-Assistant\nv1.2.1\nby Itai Nelken$(tput sgr 0)" @@ -63,6 +60,9 @@ elif [[ $1 = "--no-update" ]]; then UPDATE=0 fi +#print a "loading screen" +echo "$(tput setaf 2)$(tput bold)LOADING...$(tput sgr 0)" + #check for internet connection (disable with -ni flag) if [[ "$NOINTERNETCHECK" == 1 ]]; then PINGOUTPUT=$(ping -c 1 8.8.8.8 >/dev/null && echo '...') From 73d595d3df38c2a182680dec20e44be67c40ec8a Mon Sep 17 00:00:00 2001 From: Itai Nelken <70802936+Itai-Nelken@users.noreply.github.com> Date: Fri, 5 Feb 2021 15:27:23 +0200 Subject: [PATCH 4/5] fix syntax error in updater --- updater.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/updater.sh b/updater.sh index bf4ed4e..9d08453 100644 --- a/updater.sh +++ b/updater.sh @@ -8,7 +8,7 @@ DIRECTORY="$HOME/Pi-Assistant" APPS="$HOME/Pi-Assistant/apps" #update function -function update)() { +function update() { echo "Checking for updates..." cd $DIRECTORY localhash="$(git rev-parse HEAD)" From c40f034e61509ea6dcddd16c3477c2e561daf521 Mon Sep 17 00:00:00 2001 From: Itai Nelken <70802936+Itai-Nelken@users.noreply.github.com> Date: Fri, 5 Feb 2021 15:32:46 +0200 Subject: [PATCH 5/5] fix no-internet flag --- main.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.sh b/main.sh index efe406e..2923144 100755 --- a/main.sh +++ b/main.sh @@ -64,7 +64,7 @@ fi echo "$(tput setaf 2)$(tput bold)LOADING...$(tput sgr 0)" #check for internet connection (disable with -ni flag) -if [[ "$NOINTERNETCHECK" == 1 ]]; then +if [[ "$NOINTERNETCHECK" != 1 ]]; then PINGOUTPUT=$(ping -c 1 8.8.8.8 >/dev/null && echo '...') if [ ! "$PINGOUTPUT" = '...' ]; then UPDATE=0