AM-SAMPLE-for-zsync 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/bin/sh
  2. APP=SAMPLE
  3. URL="DIRECTURL2THEAPPIMAGE"
  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 APPIMAGE
  12. mkdir tmp
  13. wget $URL -O $APP
  14. cd ./tmp
  15. wget $URL.asc 2> /dev/null
  16. wget $URL.zsync 2> /dev/null
  17. wget $URL.zsync.asc 2> /dev/null
  18. cd ..
  19. chmod a+x /opt/$APP/$APP
  20. mv ./tmp/*mage.zsync ./$APP.zsync 2> /dev/null
  21. #mv ./tmp/*mage.asc ./$APP.asc 2> /dev/null
  22. #mv ./tmp/*zsync.asc ./$APP.zsync.asc 2> /dev/null
  23. rm -R -f ./tmp
  24. # LINK
  25. ln -s /opt/$APP/$APP /usr/local/bin/$APP
  26. # SCRIPT TO UPDATE THE PROGRAM
  27. cat >> /opt/$APP/AM-updater << 'EOF'
  28. #!/bin/sh
  29. APP=SAMPLE
  30. URL="DIRECTURL2THEAPPIMAGE"
  31. cd /opt/$APP
  32. mkdir tmp
  33. cd ./tmp
  34. wget $URL.asc 2> /dev/null
  35. wget $URL.zsync 2> /dev/null
  36. wget $URL.zsync.asc 2> /dev/null
  37. cd ..
  38. mv ./tmp/*mage.zsync ./$APP.zsync
  39. #mv ./tmp/*mage.asc ./$APP.asc
  40. #mv ./tmp/*zsync.asc ./$APP.zsync.asc
  41. rm -R -f ./tmp
  42. zsync /opt/$APP/$APP.zsync
  43. rm -R -f /opt/$APP/*zs-old /opt/$APP/*.part
  44. chmod a+x /opt/$APP/$APP
  45. EOF
  46. chmod a+x /opt/$APP/AM-updater
  47. # LAUNCHER & ICON
  48. app=$(echo $APP | cut -c -3)
  49. cd /opt/$APP
  50. ./$APP --appimage-extract *.desktop 1>/dev/null
  51. ./$APP --appimage-extract share/applications/*.desktop 1>/dev/null
  52. ./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null
  53. mv squashfs-root/*.desktop ./$APP.desktop
  54. mv squashfs-root/share/applications/*.desktop ./$APP.desktop
  55. mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop
  56. if [ ! -e ./$APP.desktop ]; then
  57. rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop
  58. mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop
  59. fi
  60. if [ ! -e ./$APP.desktop ]; then
  61. rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null
  62. mv squashfs-root/share/applications/*.desktop ./$APP.desktop
  63. fi
  64. CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1)
  65. sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop
  66. sed -i "s#AppRun#$APP#g" ./$APP.desktop
  67. sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop
  68. sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop
  69. CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1)
  70. sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop
  71. mkdir icons
  72. mv $(./$APP --appimage-extract *.png) ./icons/$APP 2>/dev/null
  73. mv $(./$APP --appimage-extract *.svg) ./icons/$APP 2>/dev/null
  74. ./$APP --appimage-extract share/icons/*/*/* 1>/dev/null
  75. ./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null
  76. ./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null
  77. ./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null
  78. mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null
  79. mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null
  80. mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null
  81. mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null
  82. mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null
  83. mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null
  84. mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null
  85. mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null
  86. mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null
  87. mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null
  88. mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null
  89. mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null
  90. mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null
  91. mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null
  92. mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null
  93. mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null
  94. mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null
  95. mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null
  96. rm -R -f /opt/$APP/squashfs-root
  97. mv ./$APP.desktop /usr/share/applications/AM-$APP.desktop
  98. # CHANGE THE PERMISSIONS
  99. currentuser=$(who | awk '{print $1}')
  100. chown -R $currentuser /opt/$APP
  101. # MESSAGE
  102. echo "
  103. $APP is provided by REPLACETHIS
  104. "