]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/Ventoy2Disk.sh
Fix for PATH with spaces (#1060)
[Ventoy.git] / INSTALL / Ventoy2Disk.sh
1 #!/bin/sh
2
3 OLDDIR=$(pwd)
4
5 if ! [ -f ./tool/ventoy_lib.sh ]; then
6 if [ -f ${0%Ventoy2Disk.sh}/tool/ventoy_lib.sh ]; then
7 cd ${0%Ventoy2Disk.sh}
8 fi
9 fi
10
11 if [ -f ./ventoy/version ]; then
12 curver=$(cat ./ventoy/version)
13 fi
14
15 if uname -m | egrep -q 'aarch64|arm64'; then
16 export TOOLDIR=aarch64
17 elif uname -m | egrep -q 'x86_64|amd64'; then
18 export TOOLDIR=x86_64
19 elif uname -m | egrep -q 'mips64'; then
20 export TOOLDIR=mips64el
21 else
22 export TOOLDIR=i386
23 fi
24 export PATH="./tool/$TOOLDIR:$PATH"
25
26
27 echo ''
28 echo '**********************************************'
29 echo " Ventoy: $curver $TOOLDIR"
30 echo " longpanda admin@ventoy.net"
31 echo " https://www.ventoy.net"
32 echo '**********************************************'
33 echo ''
34
35
36 if ! [ -f ./boot/boot.img ]; then
37 if [ -d ./grub ]; then
38 echo "Don't run Ventoy2Disk.sh here, please download the released install package, and run the script in it."
39 else
40 echo "Please run under the correct directory!"
41 fi
42 exit 1
43 fi
44
45 echo "############# Ventoy2Disk $* [$TOOLDIR] ################" >> ./log.txt
46 date >> ./log.txt
47
48 #decompress tool
49 if [ -f ./tool/$TOOLDIR/ash ]; then
50 echo "no need to decompress tools" >> ./log.txt
51 else
52 cd ./tool/$TOOLDIR
53
54 [ -f ./xzcat ] && chmod +x ./xzcat
55
56 for file in $(ls *.xz); do
57 xzcat $file > ${file%.xz}
58 [ -f ./${file%.xz} ] && chmod +x ./${file%.xz}
59 [ -f ./$file ] && rm -f ./$file
60 done
61 cd ../../
62
63 chmod +x -R ./tool/$TOOLDIR
64 fi
65
66 if [ -f /bin/bash ]; then
67 /bin/bash ./tool/VentoyWorker.sh $*
68 else
69 ash ./tool/VentoyWorker.sh $*
70 fi
71
72 if [ -n "$OLDDIR" ]; then
73 CURDIR=$(pwd)
74 if [ "$CURDIR" != "$OLDDIR" ]; then
75 cd "$OLDDIR"
76 fi
77 fi