amdgpu_top
1 #!/bin/sh 2 3 # AM INSTALL SCRIPT VERSION 3.5 4 set -u 5 APP=amdgpu_top 6 SITE="Umio-Yasuno/amdgpu_top" 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 printf '\n%s' "rm -f /usr/local/share/applications/$APP-TUI-AM.desktop" >> ../remove 13 chmod a+x ../remove || exit 1 14 15 # DOWNLOAD AND PREPARE THE APP, $version is also used for updates 16 version=$(curl -Ls https://api.github.com/repos/Umio-Yasuno/amdgpu_top/releases | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -oi "https.*$APP.*appimage$" | head -1) 17 wget "$version" || exit 1 18 #wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync 19 # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. 20 cd .. 21 mv ./tmp/*mage ./"$APP" 22 mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null 23 rm -R -f ./tmp || exit 1 24 echo "$version" > ./version 25 chmod a+x ./"$APP" || exit 1 26 27 # LINK TO PATH 28 ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" 29 30 # SCRIPT TO UPDATE THE PROGRAM 31 cat >> ./AM-updater << 'EOF' 32 #!/bin/sh 33 set -u 34 APP=amdgpu_top 35 SITE="Umio-Yasuno/amdgpu_top" 36 version0=$(cat "/opt/$APP/version") 37 version=$(curl -Ls https://api.github.com/repos/Umio-Yasuno/amdgpu_top/releases | sed 's/[()",{}]/ /g; s/ /\n/g' | grep -oi "https.*$APP.*appimage$" | head -1) 38 [ -n "$version" ] || { echo "Error getting link"; exit 1; } 39 if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then 40 mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 41 [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" 42 [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } 43 # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. 44 cd .. 45 mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" 46 [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } 47 chmod a+x ./"$APP" || exit 1 48 echo "$version" > ./version 49 rm -R -f ./*zs-old ./*.part ./tmp ./*~ 50 notify-send "$APP is updated!" 51 else 52 echo "Update not needed!" 53 fi 54 EOF 55 chmod a+x ./AM-updater || exit 1 56 57 # LAUNCHER & ICON 58 ./"$APP" --appimage-extract assets/*.desktop 1>/dev/null 59 mv squashfs-root/assets/amdgpu_top.desktop ./$APP.desktop 60 mv squashfs-root/assets/amdgpu_top-tui.desktop ./$APP-TUI.desktop 61 sed -i "s#Exec=$APP --gui#Exec=/opt/$APP/$APP --gui#g" ./$APP.desktop 62 sed -i "s#Exec=$APP#Exec=/opt/$APP/$APP#g" ./$APP-TUI.desktop 63 mv ./$APP.desktop /usr/local/share/applications/$APP-AM.desktop 64 mv ./$APP-TUI.desktop /usr/local/share/applications/$APP-TUI-AM.desktop 65 rm -R -f ./squashfs-root