supertuxkart 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. APP=supertuxkart
  3. REPO="supertuxkart/stk-code"
  4. # CREATE THE FOLDER
  5. mkdir /opt/$APP
  6. cd /opt/$APP
  7. # ADD THE REMOVER
  8. echo '#!/bin/sh' >> /opt/$APP/remove
  9. echo "rm -R -f /usr/local/share/applications/$APP-AM.desktop /opt/$APP /usr/local/bin/$APP" >> /opt/$APP/remove
  10. chmod a+x /opt/$APP/remove
  11. # DOWNLOAD THE ARCHIVE
  12. mkdir tmp
  13. cd ./tmp
  14. version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep browser_download_url | echo "$(if grep -i linux-arm64.tar.xz; then echo linux-arm64.tar.xz; else echo linux-aarch64.tar.xz; fi)" | cut -d '"' -f 4 | head -1)
  15. wget $version
  16. echo "$version" >> /opt/$APP/version
  17. cd ..
  18. tar fx ./tmp/*tar.xz -C ./tmp/ && rm -R ./tmp/*tar.xz && mv ./tmp/Super*/* . && mv ./run_game.sh ./$APP && cp ./data/*512.png . && cp ./data/*.desktop .
  19. rm -R -f ./tmp
  20. # LINK
  21. ln -s /opt/$APP/$APP /usr/local/bin/$APP
  22. # SCRIPT TO UPDATE THE PROGRAM
  23. cat >> /opt/$APP/AM-updater << 'EOF'
  24. #!/usr/bin/env bash
  25. APP=supertuxkart
  26. REPO="supertuxkart/stk-code"
  27. version0=$(cat /opt/$APP/version)
  28. version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep browser_download_url | echo "$(if grep -i linux-arm64.tar.xz; then echo linux-arm64.tar.xz; else echo linux-aarch64.tar.xz; fi)" | cut -d '"' -f 4 | head -1)
  29. if [ $version = $version0 ]; then
  30. echo "Update not needed!"
  31. else
  32. notify-send "A new version of $APP is available, please wait"
  33. mkdir /opt/$APP/tmp
  34. cd /opt/$APP/tmp
  35. wget $version
  36. cd ..
  37. tar fx ./tmp/*tar.xz -C ./tmp/ && rm -R ./tmp/*tar.xz && mv ./tmp/Super*/* . && mv ./run_game.sh ./$APP && cp ./data/*512.png . && cp ./data/*.desktop .
  38. rm ./version
  39. echo $version >> ./version
  40. rm -R -f ./tmp ./*~
  41. notify-send "$APP is updated!"
  42. fi
  43. EOF
  44. chmod a+x /opt/$APP/AM-updater
  45. # LAUNCHER & ICON
  46. app=$(echo $APP | cut -c -3)
  47. cd /opt/$APP
  48. mv ./*.desktop ./$APP.desktop 2>/dev/null
  49. CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1)
  50. sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop
  51. sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop
  52. sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop
  53. CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1)
  54. sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop
  55. mkdir icons
  56. mv ./*.svg ./icons/$APP 2>/dev/null
  57. mv ./*.png ./icons/$APP 2>/dev/null
  58. mv ./*$app*.png ./icons/$APP 2>/dev/null
  59. mv ./*128*.png ./icons/$APP 2>/dev/null
  60. mv ./*256*.png ./icons/$APP 2>/dev/null
  61. mv ./$APP.desktop /usr/local/share/applications/$APP-AM.desktop