btop 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/sh
  2. APP=btop
  3. REPO="aristocratos/btop"
  4. # CREATE DIRECTORIES
  5. if [ -z "$APP" ]; then exit 1; fi
  6. mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1
  7. # ADD THE REMOVER
  8. echo "#!/bin/sh
  9. rm -f /usr/local/share/applications/$APP-AM.desktop /usr/local/bin/$APP
  10. rm -R -f /opt/$APP" >> "/opt/$APP/remove"
  11. chmod a+x "/opt/$APP/remove"
  12. # DOWNLOAD AND PREPARE THE APP
  13. # $version is also used for updates
  14. version=$(curl -Ls https://api.github.com/repos/"$REPO"/releases/latest | grep browser_download_url | grep aarch64 | cut -d '"' -f 4 | head -1)
  15. wget "$version"
  16. tar xf ./*.tbz
  17. cd ..
  18. echo "$version" >> ./version
  19. mv ./tmp/*/* ./
  20. ln -s ./bin/btop ./"$APP"
  21. chmod a+x ./bin/btop
  22. rm -R -f ./tmp
  23. # LINK
  24. ln -s "/opt/$APP/$APP" "/usr/local/bin/$APP"
  25. # SCRIPT TO UPDATE THE PROGRAM
  26. cat >> /opt/$APP/AM-updater << 'EOF'
  27. #!/bin/sh
  28. APP=btop
  29. REPO="aristocratos/btop"
  30. version0=$(cat /opt/$APP/version)
  31. version=$(curl -Ls https://api.github.com/repos/"$REPO"/releases/latest | grep browser_download_url | grep aarch64 | cut -d '"' -f 4 | head -1)
  32. if [ "$version" = "$version0" ]; then
  33. echo "Update not needed!" || exit 0
  34. else
  35. notify-send "A new version of $APP is available, please wait"
  36. mkdir /opt/$APP/tmp && cd /opt/$APP/tmp || exit 1
  37. wget "$version"
  38. tar xf ./*.tbz
  39. cd ..
  40. rm ./version
  41. echo "$version" >> ./version
  42. mv --backup=t ./tmp/*/* ./
  43. chmod a+x ./bin/btop
  44. rm -R -f ./tmp ./*~
  45. notify-send "$APP is updated!"
  46. fi
  47. EOF
  48. chmod a+x "/opt/$APP/AM-updater"
  49. # LAUNCHER & ICON
  50. mv ./*.desktop /usr/local/share/applications/"$APP"-AM.desktop && mv ./*mg/*.svg ./icons/btop 2>/dev/null #btop already ships the files