nanosaur 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #!/bin/sh
  2. APP=nanosaur
  3. REPO="jorio/Nanosaur"
  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 ARCHIVE
  12. mkdir tmp
  13. cd ./tmp
  14. version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v x86_64 | grep browser_download_url | grep -i appimage | cut -d '"' -f 4 | head -1)
  15. wget $version
  16. echo "$version" >> /opt/$APP/version
  17. cd ..
  18. mv ./tmp/*mage ./$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=nanosaur
  27. REPO="jorio/Nanosaur"
  28. version0=$(cat /opt/$APP/version)
  29. version=$(curl -Ls https://api.github.com/repos/$REPO/releases | grep -w -v i386 | grep -w -v i686 | grep -w -v aarch64 | grep -w -v arm64 | grep -w -v armv7l | grep browser_download_url | grep -i x86_64 | grep -i appimage | cut -d '"' -f 4 | head -1)
  30. if [ $version = $version0 ]; then
  31. echo "Update not needed!"
  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 $version
  37. if ls . | grep mage; then
  38. cd ..
  39. if test -f ./tmp/*mage; then rm ./version
  40. fi
  41. echo $version >> ./version
  42. mv --backup=t ./tmp/*mage ./$APP
  43. chmod a+x /opt/$APP/$APP
  44. rm -R -f ./tmp ./*~
  45. fi
  46. notify-send "$APP is updated!"
  47. fi
  48. EOF
  49. chmod a+x /opt/$APP/AM-updater
  50. # LAUNCHER & ICON
  51. app=$(echo $APP | cut -c -3)
  52. cd /opt/$APP
  53. ./$APP --appimage-extract *.desktop 1>/dev/null
  54. ./$APP --appimage-extract share/applications/*.desktop 1>/dev/null
  55. ./$APP --appimage-extract usr/share/applications/*.desktop 1>/dev/null
  56. mv squashfs-root/*.desktop ./$APP.desktop
  57. mv squashfs-root/share/applications/*.desktop ./$APP.desktop
  58. mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop
  59. if [ ! -e ./$APP.desktop ]; then
  60. rm ./$APP.desktop; ./$APP --appimage-extract usr/share/applications/*$app*.desktop
  61. mv squashfs-root/usr/share/applications/*.desktop ./$APP.desktop
  62. fi
  63. if [ ! -e ./$APP.desktop ]; then
  64. rm ./$APP.desktop; ./$APP --appimage-extract share/applications/*$app*.desktop 1>/dev/null
  65. mv squashfs-root/share/applications/*.desktop ./$APP.desktop
  66. fi
  67. CHANGEEXEC=$(cat ./$APP.desktop | grep Exec= | tr ' ' '\n' | tr '=' '\n' | tr '/' '\n' | grep $app | head -1)
  68. sed -i "s#$CHANGEEXEC#$APP#g" ./$APP.desktop
  69. sed -i "s#AppRun#$APP#g" ./$APP.desktop
  70. sed -i "s#Exec=/bin/#Exec=#g" ./$APP.desktop
  71. sed -i "s#Exec=/usr/bin/#Exec=#g" ./$APP.desktop
  72. CHANGEICON=$(cat ./$APP.desktop | grep Icon= | head -1)
  73. sed -i "s#$CHANGEICON#Icon=/opt/$APP/icons/$APP#g" ./$APP.desktop
  74. mkdir icons
  75. ./$APP --appimage-extract *.png 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null
  76. ./$APP --appimage-extract *.svg 2>&1 | grep -v "squashfs-root"; mv ./squashfs-root/*$app* ./icons/$APP 2>/dev/null
  77. ./$APP --appimage-extract share/icons/*/*/* 1>/dev/null
  78. ./$APP --appimage-extract usr/share/icons/*/*/* 1>/dev/null
  79. ./$APP --appimage-extract share/icons/*/*/*/* 1>/dev/null
  80. ./$APP --appimage-extract usr/share/icons/*/*/*/* 1>/dev/null
  81. mv ./squashfs-root/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null
  82. mv ./squashfs-root/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null
  83. mv ./squashfs-root/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null
  84. mv ./squashfs-root/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null
  85. mv ./squashfs-root/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null
  86. mv ./squashfs-root/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null
  87. mv ./squashfs-root/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null
  88. mv ./squashfs-root/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null
  89. mv ./squashfs-root/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null
  90. mv ./squashfs-root/usr/share/icons/hicolor/22x22/apps/*$app* ./icons/$APP 2>/dev/null
  91. mv ./squashfs-root/usr/share/icons/hicolor/24x24/apps/*$app* ./icons/$APP 2>/dev/null
  92. mv ./squashfs-root/usr/share/icons/hicolor/32x32/apps/*$app* ./icons/$APP 2>/dev/null
  93. mv ./squashfs-root/usr/share/icons/hicolor/48x48/apps/*$app* ./icons/$APP 2>/dev/null
  94. mv ./squashfs-root/usr/share/icons/hicolor/64x64/apps/*$app* ./icons/$APP 2>/dev/null
  95. mv ./squashfs-root/usr/share/icons/hicolor/128x128/apps/*$app* ./icons/$APP 2>/dev/null
  96. mv ./squashfs-root/usr/share/icons/hicolor/256x256/apps/*$app* ./icons/$APP 2>/dev/null
  97. mv ./squashfs-root/usr/share/icons/hicolor/512x512/apps/*$app* ./icons/$APP 2>/dev/null
  98. mv ./squashfs-root/usr/share/icons/hicolor/scalable/apps/*$app* ./icons/$APP 2>/dev/null
  99. rm -R -f /opt/$APP/squashfs-root
  100. mv ./$APP.desktop /usr/local/share/applications/$APP-AM.desktop