AM-SAMPLE-AUR-generic 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/sh
  2. APP=SAMPLE
  3. SITE="REPLACETHIS"
  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/share/applications/AM-$APP.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=$(echo $(wget -q https://aur.archlinux.org/packages/AURREPO -O - | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep -i "FILENAMEEXTENSION" | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep -w -v ".asc" | grep -w -v "archlinux.org" | head -1))
  15. wget $version
  16. echo "$version" >> /opt/$APP/version
  17. cd ..
  18. FUNCTION
  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=SAMPLE
  26. version0=$(cat /opt/$APP/version)
  27. version=$(echo $(wget -q https://aur.archlinux.org/packages/AURREPO -O - | grep -Eo "(http|https)://[a-zA-Z0-9./?=_%:-]*" | grep -i "FILENAMEEXTENSION" | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep -w -v ".asc" | grep -w -v "archlinux.org" | head -1))
  28. if [ $version = $version0 ]; then
  29. echo "Update not needed!"
  30. else
  31. notify-send "A new version of $APP is available, please wait"
  32. mkdir /opt/$APP/tmp
  33. cd /opt/$APP/tmp
  34. wget $version
  35. cd ..
  36. FUNCTION
  37. rm ./version
  38. echo $version >> ./version
  39. rm -R -f ./tmp ./*~
  40. notify-send "$APP is updated!"
  41. fi
  42. EOF
  43. chmod a+x /opt/$APP/AM-updater
  44. # LAUNCHER & ICON
  45. app=$(echo $APP | cut -c -3)
  46. cd /opt/$APP
  47. mv ./*.desktop ./$APP.desktop 2>/dev/null
  48. CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1)
  49. sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop
  50. sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop
  51. sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop
  52. CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1)
  53. sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop
  54. mkdir icons
  55. mv ./*.svg ./icons/$APP 2>/dev/null
  56. mv ./*.png ./icons/$APP 2>/dev/null
  57. mv ./*$app*.png ./icons/$APP 2>/dev/null
  58. mv ./*128*.png ./icons/$APP 2>/dev/null
  59. mv ./*256*.png ./icons/$APP 2>/dev/null
  60. mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop
  61. # CHANGE THE PERMISSIONS
  62. currentuser=$(who | awk '{print $1}')
  63. chown -R $currentuser /opt/$APP
  64. # MESSAGE
  65. echo "
  66. $APP is provided by $SITE
  67. "