AM-SAMPLE-Archive 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. # AM INSTALL SCRIPT VERSION 3.5
  3. set -u
  4. APP=SAMPLE
  5. SITE="REPLACETHIS"
  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=$(FUNCTION)
  13. wget "$version" || exit 1
  14. [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
  15. [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
  16. [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
  17. cd ..
  18. if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi
  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=SAMPLE
  29. SITE="REPLACETHIS"
  30. version0=$(cat "/opt/$APP/version")
  31. version=$(FUNCTION)
  32. [ -n "$version" ] || { echo "Error getting link"; exit 1; }
  33. if [ "$version" != "$version0" ]; then
  34. mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
  35. notify-send "A new version of $APP is available, please wait"
  36. wget "$version" || exit 1
  37. [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
  38. [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
  39. [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
  40. cd ..
  41. if [ -d ./tmp/* 2>/dev/null ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/* ./"$APP" 2>/dev/null || mv --backup=t ./tmp/* ./; fi
  42. chmod a+x ./"$APP" || exit 1
  43. echo "$version" > ./version
  44. rm -R -f ./tmp ./*~
  45. notify-send "$APP is updated!"
  46. else
  47. echo "Update not needed!"
  48. fi
  49. EOF
  50. chmod a+x ./AM-updater || exit 1