ksirk 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. # AM INSTALL SCRIPT VERSION 3.5
  3. set -u
  4. APP=kdegames
  5. SITE="ivan-hc/32-bit-AppImage-packages-database"
  6. # CREATE DIRECTORIES AND ADD REMOVER
  7. [ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1
  8. printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > ../remove
  9. printf '\n%s' "rm -f /usr/local/share/applications/$APP*-AM.desktop" >> ../remove
  10. chmod a+x ../remove || exit 1
  11. # DOWNLOAD AND PREPARE THE APP, $version is also used for updates
  12. 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)
  13. wget "$version" || exit 1
  14. #wget "$version.zsync" 2> /dev/null # Comment out this line if you want to use zsync
  15. # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
  16. cd ..
  17. mv ./tmp/*mage ./"$APP"
  18. mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null
  19. rm -R -f ./tmp || exit 1
  20. echo "$version" > ./version
  21. chmod a+x ./"$APP" || exit 1
  22. # LINK TO PATH
  23. ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
  24. # SCRIPT TO UPDATE THE PROGRAM
  25. cat >> ./AM-updater << 'EOF'
  26. #!/bin/sh
  27. set -u
  28. APP=kdegames
  29. SITE="ivan-hc/32-bit-AppImage-packages-database"
  30. version0=$(cat "/opt/$APP/version")
  31. 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)
  32. [ -n "$version" ] || { echo "Error getting link"; exit 1; }
  33. if [ "$version" != "$version0" ] || [ -e /opt/"$APP"/*.zsync ]; then
  34. mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
  35. [ -e ../*.zsync ] || notify-send "A new version of $APP is available, please wait"
  36. [ -e ../*.zsync ] && wget "$version.zsync" 2>/dev/null || { wget "$version" || exit 1; }
  37. # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
  38. cd ..
  39. mv ./tmp/*.zsync ./"$APP".zsync 2>/dev/null || mv --backup=t ./tmp/*mage ./"$APP"
  40. [ -e ./*.zsync ] && { zsync ./"$APP".zsync || notify-send -u critical "zsync failed to update $APP"; }
  41. chmod a+x ./"$APP" || exit 1
  42. echo "$version" > ./version
  43. rm -R -f ./*zs-old ./*.part ./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
  50. # LAUNCHER & ICON
  51. ./kdegames --appimage-extract > /dev/null
  52. cp ./squashfs-root/usr/share/icons/hicolor/22x22/apps/* /opt/"$APP"/icons/ 2>/dev/null
  53. cp ./squashfs-root/usr/share/icons/hicolor/24x24/apps/* /opt/"$APP"/icons/ 2>/dev/null
  54. cp ./squashfs-root/usr/share/icons/hicolor/32x32/apps/* /opt/"$APP"/icons/ 2>/dev/null
  55. cp ./squashfs-root/usr/share/icons/hicolor/48x48/apps/* /opt/"$APP"/icons/ 2>/dev/null
  56. cp ./squashfs-root/usr/share/icons/hicolor/64x64/apps/* /opt/"$APP"/icons/ 2>/dev/null
  57. cp ./squashfs-root/usr/share/icons/hicolor/128x128/apps/* /opt/"$APP"/icons/ 2>/dev/null
  58. cp ./squashfs-root/usr/share/icons/hicolor/256x256/apps/* /opt/"$APP"/icons/ 2>/dev/null
  59. cp ./squashfs-root/usr/share/icons/hicolor/512x512/apps/* /opt/"$APP"/icons/ 2>/dev/null
  60. cp ./squashfs-root/usr/share/icons/hicolor/scalable/apps/* /opt/"$APP"/icons/ 2>/dev/null
  61. cd /opt/"$APP"/icons || exit 1
  62. for file in *.png; do mv -- "$file" "${file%%.png}"; done
  63. cd ..
  64. mkdir /opt/"$APP"/launchers
  65. cp ./squashfs-root/usr/share/applications/* /opt/"$APP"/launchers/ 2>/dev/null
  66. cd /opt/"$APP"/launchers
  67. for f in *; do mv "$f" "$APP-${f%.desktop}-AM.desktop"; done
  68. sed -i "s#Exec=#Exec=/opt/kdegames/kdegames #g" /opt/"$APP"/launchers/*.desktop
  69. sed -i "s#Icon=#Icon=/opt/kdegames/icons/#g" /opt/"$APP"/launchers/*.desktop
  70. cp /opt/"$APP"/launchers/*.desktop /usr/local/share/applications/
  71. rm -R -f /opt/"$APP"/launchers
  72. rm -R -f ./squashfs-root