katomic 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. # Keep this space in sync with other installation scripts
  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. # Keep this space in sync with other installation scripts
  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 command -v appimageupdatetool >/dev/null 2>&1; then
  34. cd "/opt/$APP" || exit 1
  35. appimageupdatetool -Or ./"$APP" && chmod a+x ./"$APP" && echo "$version" > ./version && exit 0
  36. fi
  37. if [ "$version" != "$version0" ]; then
  38. mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
  39. wget "$version" || exit 1
  40. # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
  41. cd ..
  42. mv --backup=t ./tmp/*mage ./"$APP"
  43. chmod a+x ./"$APP" || exit 1
  44. echo "$version" > ./version
  45. rm -R -f ./*zs-old ./*.part ./tmp ./*~
  46. notify-send "$APP is updated!"
  47. else
  48. echo "Update not needed!"
  49. fi
  50. EOF
  51. chmod a+x ./AM-updater || exit 1
  52. # LAUNCHER & ICON
  53. ./kdegames --appimage-extract > /dev/null
  54. cp ./squashfs-root/usr/share/icons/hicolor/22x22/apps/* /opt/"$APP"/icons/ 2>/dev/null
  55. cp ./squashfs-root/usr/share/icons/hicolor/24x24/apps/* /opt/"$APP"/icons/ 2>/dev/null
  56. cp ./squashfs-root/usr/share/icons/hicolor/32x32/apps/* /opt/"$APP"/icons/ 2>/dev/null
  57. cp ./squashfs-root/usr/share/icons/hicolor/48x48/apps/* /opt/"$APP"/icons/ 2>/dev/null
  58. cp ./squashfs-root/usr/share/icons/hicolor/64x64/apps/* /opt/"$APP"/icons/ 2>/dev/null
  59. cp ./squashfs-root/usr/share/icons/hicolor/128x128/apps/* /opt/"$APP"/icons/ 2>/dev/null
  60. cp ./squashfs-root/usr/share/icons/hicolor/256x256/apps/* /opt/"$APP"/icons/ 2>/dev/null
  61. cp ./squashfs-root/usr/share/icons/hicolor/512x512/apps/* /opt/"$APP"/icons/ 2>/dev/null
  62. cp ./squashfs-root/usr/share/icons/hicolor/scalable/apps/* /opt/"$APP"/icons/ 2>/dev/null
  63. cd /opt/"$APP"/icons || exit 1
  64. for file in *.png; do mv -- "$file" "${file%%.png}"; done
  65. cd ..
  66. mkdir /opt/"$APP"/launchers
  67. cp ./squashfs-root/usr/share/applications/* /opt/"$APP"/launchers/ 2>/dev/null
  68. cd /opt/"$APP"/launchers
  69. for f in *; do mv "$f" "$APP-${f%.desktop}-AM.desktop"; done
  70. sed -i "s#Exec=#Exec=/opt/kdegames/kdegames #g" /opt/"$APP"/launchers/*.desktop
  71. sed -i "s#Icon=#Icon=/opt/kdegames/icons/#g" /opt/"$APP"/launchers/*.desktop
  72. cp /opt/"$APP"/launchers/*.desktop /usr/local/share/applications/
  73. rm -R -f /opt/"$APP"/launchers
  74. rm -R -f ./squashfs-root