ksirk
1 #!/bin/sh 2 3 # AM INSTALL SCRIPT VERSION 3.5 4 set -u 5 APP=kdegames 6 SITE="ivan-hc/32-bit-AppImage-packages-database" 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/ivan-hc/32-bit-AppImage-packages-database/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*kdegames.*mage$" | head -1) 16 wget "$version" || exit 1 17 #wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync 18 # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. 19 cd .. 20 mv ./tmp/*mage ./"$APP" 21 mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null 22 rm -R -f ./tmp || exit 1 23 echo "$version" > ./version 24 chmod a+x ./"$APP" || exit 1 25 26 # LINK TO PATH 27 ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP" 28 29 # SCRIPT TO UPDATE THE PROGRAM 30 cat >> ./AM-updater << 'EOF' 31 #!/bin/sh 32 set -u 33 APP=kdegames 34 SITE="ivan-hc/32-bit-AppImage-packages-database" 35 version0=$(cat "/opt/$APP/version") 36 version=$(curl -Ls https://api.github.com/repos/ivan-hc/32-bit-AppImage-packages-database/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*kdegames.*mage$" | head -1) 37 [ -n "$version" ] || { echo "Error getting link"; exit 1; } 38 if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then 39 mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1 40 [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait" 41 [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; } 42 # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded. 43 cd .. 44 mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP" 45 [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; } 46 chmod a+x ./"$APP" || exit 1 47 echo "$version" > ./version 48 rm -R -f ./*zs-old ./*.part ./tmp ./*~ 49 notify-send "$APP is updated!" 50 else 51 echo "Update not needed!" 52 fi 53 EOF 54 chmod a+x ./AM-updater || exit 1 55 56 # LAUNCHER & ICON 57 ./kdegames --appimage-extract > /dev/null 58 cp ./squashfs-root/usr/share/icons/hicolor/22x22/apps/* /opt/"$APP"/icons/ 2>/dev/null 59 cp ./squashfs-root/usr/share/icons/hicolor/24x24/apps/* /opt/"$APP"/icons/ 2>/dev/null 60 cp ./squashfs-root/usr/share/icons/hicolor/32x32/apps/* /opt/"$APP"/icons/ 2>/dev/null 61 cp ./squashfs-root/usr/share/icons/hicolor/48x48/apps/* /opt/"$APP"/icons/ 2>/dev/null 62 cp ./squashfs-root/usr/share/icons/hicolor/64x64/apps/* /opt/"$APP"/icons/ 2>/dev/null 63 cp ./squashfs-root/usr/share/icons/hicolor/128x128/apps/* /opt/"$APP"/icons/ 2>/dev/null 64 cp ./squashfs-root/usr/share/icons/hicolor/256x256/apps/* /opt/"$APP"/icons/ 2>/dev/null 65 cp ./squashfs-root/usr/share/icons/hicolor/512x512/apps/* /opt/"$APP"/icons/ 2>/dev/null 66 cp ./squashfs-root/usr/share/icons/hicolor/scalable/apps/* /opt/"$APP"/icons/ 2>/dev/null 67 cd /opt/"$APP"/icons || exit 1 68 for file in *.png; do mv -- "$file" "${file%%.png}"; done 69 cd .. 70 71 mkdir /opt/"$APP"/launchers 72 cp ./squashfs-root/usr/share/applications/* /opt/"$APP"/launchers/ 2>/dev/null 73 cd /opt/"$APP"/launchers 74 for f in *; do mv "$f" "$APP-${f%.desktop}-AM.desktop"; done 75 sed -i "s#Exec=#Exec=/opt/kdegames/kdegames #g" /opt/"$APP"/launchers/*.desktop 76 sed -i "s#Icon=#Icon=/opt/kdegames/icons/#g" /opt/"$APP"/launchers/*.desktop 77 cp /opt/"$APP"/launchers/*.desktop /usr/local/share/applications/ 78 79 rm -R -f /opt/"$APP"/launchers 80 rm -R -f ./squashfs-root