-print_usage() {
- echo 'Usage: VentoyInstaller.sh OPTION /dev/sdX'
- echo ' OPTION:'
- echo ' -i install ventoy to sdX (fail if disk already installed with ventoy)'
- echo ' -u update ventoy in sdX'
- echo ' -I force install ventoy to sdX (no matter installed or not)'
- echo ''
-}
-
-echo ''
-echo '***********************************************************'
-echo '* Ventoy2Disk Script *'
-echo '* longpanda admin@ventoy.net *'
-echo '***********************************************************'
-echo ''
-
-vtdebug "############# Ventoy2Disk ################"
-
-if ! [ -e ventoy/version ]; then
- vterr "Please run under the correct directory!"
- exit 1
-fi
-
-if [ "$1" = "-i" ]; then
- MODE="install"
-elif [ "$1" = "-I" ]; then
- MODE="install"
- FORCE="Y"
-elif [ "$1" = "-u" ]; then
- MODE="update"
-else
- print_usage
- exit 1
-fi
-
-if ! [ -b "$2" ]; then
- print_usage
- exit 1
-fi
-
-if [ -z "$SUDO_USER" ]; then
- if [ "$USER" != "root" ]; then
- vterr "EUID is $EUID root permission is required."
- echo ''
- exit 1
- fi
-fi
-
-vtdebug "MODE=$MODE FORCE=$FORCE"
-
-#decompress tool
-cd tool
-chmod +x ./xzcat
-for file in $(ls); do
- if [ "$file" != "xzcat" ]; then
- if [ "$file" != "ventoy_lib.sh" ]; then
- ./xzcat $file > ${file%.xz}
- chmod +x ${file%.xz}
- fi