legcord 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. # AM INSTALL SCRIPT VERSION 3.5
  3. set -u
  4. APP=legcord
  5. SITE="Legcord/Legcord"
  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/Legcord/Legcord/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*arm64.*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=legcord
  29. SITE="Legcord/Legcord"
  30. version0=$(cat "/opt/$APP/version")
  31. version=$(curl -Ls https://api.github.com/repos/Legcord/Legcord/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*arm64.*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. notify-send "A new version of $APP is available, please wait"
  40. wget "$version" || exit 1
  41. # Use tar fx ./*tar* here for example in this line in case a compressed file is downloaded.
  42. cd ..
  43. mv --backup=t ./tmp/*mage ./"$APP"
  44. chmod a+x ./"$APP" || exit 1
  45. echo "$version" > ./version
  46. rm -R -f ./*zs-old ./*.part ./tmp ./*~
  47. notify-send "$APP is updated!"
  48. else
  49. echo "Update not needed!"
  50. fi
  51. EOF
  52. chmod a+x ./AM-updater || exit 1
  53. # LAUNCHER & ICON
  54. ./"$APP" --appimage-extract *.desktop 1>/dev/null && mv ./squashfs-root/*.desktop ./"$APP".desktop
  55. ./"$APP" --appimage-extract .DirIcon 1>/dev/null && mv ./squashfs-root/.DirIcon ./DirIcon
  56. COUNT=0
  57. while [ "$COUNT" -lt 10 ]; do # Tries to get the actual icon/desktop if it is a symlink to another symlink
  58. if [ -L ./"$APP".desktop ]; then
  59. LINKPATH="$(readlink ./"$APP".desktop | sed 's|^\./||' 2>/dev/null)"
  60. ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./"$APP".desktop
  61. fi
  62. if [ -L ./DirIcon ]; then
  63. LINKPATH="$(readlink ./DirIcon | sed 's|^\./||' 2>/dev/null)"
  64. ./"$APP" --appimage-extract "$LINKPATH" 1>/dev/null && mv ./squashfs-root/"$LINKPATH" ./DirIcon
  65. fi
  66. [ ! -L ./"$APP".desktop ] && [ ! -L ./DirIcon ] && break
  67. COUNT=$((COUNT + 1))
  68. done
  69. sed -i "s#Exec=[^ ]*#Exec=$APP#g; s#Icon=.*#Icon=/opt/$APP/icons/$APP#g" ./"$APP".desktop
  70. mv ./"$APP".desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./DirIcon ./icons/"$APP" 1>/dev/null
  71. rm -R -f ./squashfs-root