ventoy 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/sh
  2. # AM INSTALL SCRIPT VERSION 3.
  3. set -u
  4. APP=ventoy
  5. SITE="ventoy/Ventoy"
  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=$(curl -Ls https://api.github.com/repos/ventoy/Ventoy/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*" | grep -i "linux.tar.gz" | head -1)
  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 ./VentoyGUI.i386 || exit 1
  22. # SCRIPT TO LAUNCH THE PROGRAM
  23. echo '#!/bin/sh
  24. exec /opt/'$APP'/VentoyGUI.i386' >> /usr/local/bin/"$APP"
  25. chmod a+x /usr/local/bin/"$APP"
  26. # SCRIPT TO UPDATE THE PROGRAM
  27. cat >> ./AM-updater << 'EOF'
  28. #!/bin/sh
  29. set -u
  30. APP=ventoy
  31. SITE="ventoy/Ventoy"
  32. version0=$(cat "/opt/$APP/version")
  33. version=$(curl -Ls https://api.github.com/repos/ventoy/Ventoy/releases | sed 's/[()",{} ]/\n/g' | grep -oi "https.*" | grep -i "linux.tar.gz" | head -1)
  34. [ -n "$version" ] || { echo "Error getting link"; exit 1; }
  35. if [ "$version" != "$version0" ]; then
  36. mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
  37. notify-send "A new version of $APP is available, please wait"
  38. wget "$version" || exit 1
  39. [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
  40. [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
  41. [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
  42. cd ..
  43. 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
  44. chmod a+x ./VentoyGUI.i386 || exit 1
  45. echo "$version" > ./version
  46. rm -R -f ./tmp ./*~
  47. notify-send "$APP is updated!"
  48. else
  49. echo "Update not needed!"
  50. fi
  51. EOF
  52. chmod a+x ./AM-updater || exit 1
  53. # ICON
  54. mkdir -p icons
  55. wget https://www.ventoy.net/static/img/ventoy.png -O ./icons/"$APP" 2> /dev/null
  56. # LAUNCHER
  57. echo "[Desktop Entry]
  58. Name=Ventoy
  59. Comment=Open source tool to create bootable USB drive for ISO/WIM/IMG/VHD(x)/EFI files.
  60. Exec=$APP
  61. Icon=/opt/$APP/icons/$APP
  62. Type=Application
  63. Categories=System;" > /usr/local/share/applications/"$APP"-AM.desktop