zap 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #!/bin/sh
  2. APP=zap
  3. BINARY=zap-arm64
  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 PROGRAM
  12. mkdir tmp
  13. cd ./tmp
  14. v=$(curl -Ls https://api.github.com/repos/srevinsaju/zap/releases/latest | grep -E tag_name | awk -F '[""]' '{print $4}')
  15. wget https://github.com/srevinsaju/zap/releases/download/$v/$BINARY
  16. echo $v >> /opt/$APP/version
  17. cd ..
  18. mv ./tmp/$BINARY ./$APP
  19. chmod a+x /opt/$APP/$APP
  20. rmdir ./tmp
  21. # LINK
  22. ln -s /opt/$APP/$APP /usr/local/bin/$APP
  23. # SCRIPT TO UPDATE THE PROGRAM
  24. cat >> /opt/$APP/AM-updater << 'EOF'
  25. #!/usr/bin/env bash
  26. APP=zap
  27. BINARY=zap-arm64
  28. version0=$(cat /opt/$APP/version)
  29. v=$(curl -Ls https://api.github.com/repos/srevinsaju/zap/releases/latest | grep -E tag_name | awk -F '[""]' '{print $4}')
  30. if [ "$version0" == "$v" ]; then
  31. echo "Update not needed, exit!"
  32. else
  33. notify-send "A new version of '$APP' is available, please wait!"
  34. mkdir /opt/$APP/tmp
  35. cd /opt/$APP/tmp
  36. wget https://github.com/srevinsaju/zap/releases/download/$v/$BINARY
  37. rm -R /opt/$APP/version
  38. echo $v >> /opt/$APP/version
  39. cd ..
  40. mv /opt/$APP/tmp/$BINARY /opt/$APP/$APP
  41. chmod a+x /opt/$APP/$APP
  42. rm -R -f /opt/$APP/tmp
  43. fi
  44. EOF
  45. chmod a+x /opt/$APP/AM-updater