nerdfetch
1 #!/bin/sh 2 3 # AM INSTALL SCRIPT VERSION 3.5 4 set -u 5 APP=nerdfetch 6 SITE="ThatOneCalculator/NerdFetch" 7 8 # CREATE DIRECTORIES AND ADD REMOVER 9 [ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1 10 printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > ../remove 11 #printf '\n%s' "rm -f /usr/local/share/applications/$APP-AM.desktop" >> ../remove 12 chmod a+x ../remove || exit 1 13 14 # DOWNLOAD AND PREPARE THE APP, $version is also used for updates 15 version=$(curl -Ls https://api.github.com/repos/ThatOneCalculator/NerdFetch/releases/latest | grep tag | cut -d '"' -f 4 | head -1) 16 wget https://raw.githubusercontent.com/ThatOneCalculator/NerdFetch/main/nerdfetch || exit 1 17 cd .. 18 if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi 19 rm -R -f ./tmp || exit 1 20 echo "$version" > ./version 21 chmod a+x ./"$APP" || exit 1 22 23 # LINK TO PATH 24 ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" 25 26 # SCRIPT TO UPDATE THE PROGRAM 27 cat >> ./AM-updater << 'EOF' 28 #!/bin/sh 29 set -u 30 APP=nerdfetch 31 SITE="ThatOneCalculator/NerdFetch" 32 version0=$(cat "/opt/$APP/version") 33 version=$(curl -Ls https://api.github.com/repos/ThatOneCalculator/NerdFetch/releases/latest | grep tag | cut -d '"' -f 4 | head -1) 34 [ -n "$version" ] || { echo "Error getting link"; exit 1; } 35 if [ "$version" != "$version0" ]; then 36 mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 37 notify-send "A new version of $APP is available, please wait" 38 wget https://raw.githubusercontent.com/ThatOneCalculator/NerdFetch/main/nerdfetch || exit 1 39 cd .. 40 if [ -d ./tmp/* 2>/dev/null ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/* ./"$APP" 2>/dev/null || mv --backup=t ./tmp/* ./; fi 41 chmod a+x ./"$APP" || exit 1 42 echo "$version" > ./version 43 rm -R -f ./tmp ./*~ 44 notify-send "$APP is updated!" 45 else 46 echo "Update not needed!" 47 fi 48 EOF 49 chmod a+x ./AM-updater || exit 1