X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/d80a008c04872ca89d51c3d414e1834d317d8519..HEAD:/INSTALL/Ventoy2Disk.sh diff --git a/INSTALL/Ventoy2Disk.sh b/INSTALL/Ventoy2Disk.sh index 06521af..f08ab10 100644 --- a/INSTALL/Ventoy2Disk.sh +++ b/INSTALL/Ventoy2Disk.sh @@ -1,21 +1,38 @@ #!/bin/sh +OLDDIR=$(pwd) -echo '' -echo '***********************************************************' -echo '* Ventoy2Disk Script *' -echo '* longpanda admin@ventoy.net *' -echo '***********************************************************' -echo '' - -OLDDIR=$PWD - -if ! [ -f ./tool/xzcat ]; then - if [ -f ${0%Ventoy2Disk.sh}/tool/xzcat ]; then +if ! [ -f ./tool/ventoy_lib.sh ]; then + if [ -f ${0%Ventoy2Disk.sh}/tool/ventoy_lib.sh ]; then cd ${0%Ventoy2Disk.sh} fi fi +if [ -f ./ventoy/version ]; then + curver=$(cat ./ventoy/version) +fi + +if uname -m | grep -E -q 'aarch64|arm64'; then + export TOOLDIR=aarch64 +elif uname -m | grep -E -q 'x86_64|amd64'; then + export TOOLDIR=x86_64 +elif uname -m | grep -E -q 'mips64'; then + export TOOLDIR=mips64el +else + export TOOLDIR=i386 +fi +export PATH="./tool/$TOOLDIR:$PATH" + + +echo '' +echo '**********************************************' +echo " Ventoy: $curver $TOOLDIR" +echo " longpanda admin@ventoy.net" +echo " https://www.ventoy.net" +echo '**********************************************' +echo '' + + if ! [ -f ./boot/boot.img ]; then if [ -d ./grub ]; then echo "Don't run Ventoy2Disk.sh here, please download the released install package, and run the script in it." @@ -25,31 +42,38 @@ if ! [ -f ./boot/boot.img ]; then exit 1 fi -echo "############# Ventoy2Disk $* ################" >> ./log.txt +echo "############# Ventoy2Disk $* [$TOOLDIR] ################" >> ./log.txt +date >> ./log.txt #decompress tool -if ! [ -f ./tool/ash ]; then - cd tool - chmod +x ./xzcat +echo "decompress tools" >> ./log.txt +cd ./tool/$TOOLDIR + +ls *.xz > /dev/null 2>&1 +if [ $? -eq 0 ]; then + [ -f ./xzcat ] && chmod +x ./xzcat + for file in $(ls *.xz); do - ./xzcat $file > ${file%.xz} - chmod +x ${file%.xz} + echo "decompress $file" >> ./log.txt + xzcat $file > ${file%.xz} + [ -f ./${file%.xz} ] && chmod +x ./${file%.xz} + [ -f ./$file ] && rm -f ./$file done - cd ../ - - if ! [ -f ./tool/ash ]; then - echo 'Failed to decompress tools ...' - if [ -n "$OLDDIR" ]; then - cd $OLDDIR - fi - exit 1 - fi fi -./tool/ash ./tool/VentoyWorker.sh $* +cd ../../ +chmod +x -R ./tool/$TOOLDIR -if [ -n "$OLDDIR" ]; then - cd $OLDDIR -fi +if [ -f /bin/bash ]; then + /bin/bash ./tool/VentoyWorker.sh $* +else + ash ./tool/VentoyWorker.sh $* +fi +if [ -n "$OLDDIR" ]; then + CURDIR=$(pwd) + if [ "$CURDIR" != "$OLDDIR" ]; then + cd "$OLDDIR" + fi +fi