]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/VentoyPlugson.sh
6 echo 'Usage: sudo sh VentoyPlugson.sh [OPTION] /dev/sdX'
7 echo ' OPTION: (optional)'
8 echo ' -H x.x.x.x http server IP address (default is 127.0.0.1)'
9 echo ' -P PORT http server PORT (default is 24681)'
10 echo ' -h print this help'
15 if [ $uid -ne 0 ]; then
16 echo "Please use sudo or run the script as root."
24 if echo $machine | egrep -q 'aarch64|arm64'; then
26 elif echo $machine | egrep -q 'x86_64|amd64'; then
28 elif echo $machine | egrep -q 'mips64'; then
30 elif echo $machine | egrep -q 'i[3-6]86'; then
33 echo "Unsupported machine type $machine"
38 if ! [ -f "$OLDDIR/tool/plugson.tar.xz" ]; then
39 echo "Please run under the correct directory!"
43 echo "############# VentoyPlugson $* [$TOOLDIR] ################" >> .
/VentoyPlugson.log
44 date >> .
/VentoyPlugson.log
46 echo "decompress tools" >> .
/VentoyPlugson.log
49 ls *.xz
> /dev
/null
2>&1
51 [ -f .
/xzcat
] && chmod +x .
/xzcat
53 for file in $(ls *.xz); do
54 echo "decompress $file" >> .
/VentoyPlugson.log
55 xzcat
$file > ${file%.xz}
56 [ -f .
/${file%.xz} ] && chmod +x .
/${file%.xz}
57 [ -f .
/$file ] && rm -f .
/$file
62 chmod +x
-R .
/tool
/$TOOLDIR
64 if ! [ -f "$OLDDIR/tool/$TOOLDIR/Plugson" ]; then
65 echo "$OLDDIR/tool/$TOOLDIR/Plugson does not exist!"
70 PATH
=.
/tool
/$TOOLDIR:$PATH
76 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
79 elif [ "$1" = "-H" ]; then
81 if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
84 echo "Invalid host $1"
87 elif [ "$1" = "-P" ]; then
89 if [ $1 -gt 0 -a $1 -le 65535 ]; then
92 echo "Invalid port $1"
102 if [ -z "$DISK" ]; then
107 if ps
-ef | grep "tool/$TOOLDIR/Plugson.*$HOST.*$PORT" | grep -q -v grep; then
108 echo "Another ventoy server is running now, please close it first."
112 if echo $DISK | grep -q "[a-z]d[a-z][1-9]"; then
116 if echo $DISK | egrep -q "/dev/nvme|/dev/mmcblk/dev/nbd"; then
117 if echo $DISK | grep -q "p[1-9]$"; then
123 if [ ! -b "$DISK" ]; then
124 echo "$DISK does NOT exist."
129 version
=$(get_disk_ventoy_version $DISK)
130 if [ $?
-eq 0 ]; then
131 echo "Ventoy version in Disk: $version"
133 vtPart1Type
=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
134 if [ "$vtPart1Type" = "EE" ]; then
135 echo "Disk Partition Style : GPT"
138 echo "Disk Partition Style : MBR"
142 if check_disk_secure_boot
$DISK; then
143 echo "Secure Boot Support : YES"
146 echo "Secure Boot Support : NO"
150 echo "$DISK is NOT Ventoy disk."
154 PART1
=$(get_disk_part_name $DISK 1)
156 if grep -q "^$PART1 " /proc
/mounts
; then
157 mtpnt
=$(grep "^$PART1 " /proc/mounts | awk '{print $2}')
158 fstype
=$(grep "^$PART1 " /proc/mounts | awk '{print $3}')
160 if echo $fstype | grep -q -i 'fuse'; then
161 if hexdump -C -n 16 $PART1 | grep -q -i "EXFAT"; then
163 elif hexdump -C -n 16 $PART1 | grep -q -i "NTFS"; then
168 echo "$PART1 is mounted at $mtpnt $fstype"
170 echo "$PART1 is NOT mounted, please mount it first!"
174 if [ -d "$mtpnt/ventoy" ]; then
175 echo "ventoy directory exist OK"
177 echo "create ventoy directory"
178 mkdir -p "$mtpnt/ventoy"
179 if [ -d "$mtpnt/ventoy" ]; then
180 chmod -R 0755 "$mtpnt/ventoy"
182 echo "Failed to create directory $mtpnt/ventoy"
188 #change current directory to Ventoy disk
190 $OLDDIR/tool
/$TOOLDIR/Plugson
"$HOST" "$PORT" "$OLDDIR" "$DISK" $version "$fstype" $partstyle $secureboot &
194 if [ -f /proc
/$wID/maps
]; then
196 echo "==============================================================="
197 if [ "$LANG" = "zh_CN.UTF-8" ]; then
198 echo " Ventoy Plugson Server 已经启动 ..."
199 echo " 请打开浏览器,访问 http://${HOST}:${PORT}"
201 echo " Ventoy Plugson Server is running ..."
202 echo " Please open your browser and visit http://${HOST}:${PORT}"
204 echo "==============================================================="
206 echo "################## Press Ctrl + C to exit #####################"
213 if [ -n "$OLDDIR" ]; then
215 if [ "$CURDIR" != "$OLDDIR" ]; then