]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/VentoyPlugson.sh
6 echo 'Usage: sudo bash 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."
20 if [ "$1" = "__vbash__" ]; then
23 if readlink
/bin
/sh
| grep -q bash
; then
26 exec /bin
/bash
$0 "__vbash__" "$@"
33 if echo $machine | grep -E -q 'aarch64|arm64'; then
35 elif echo $machine | grep -E -q 'x86_64|amd64'; then
37 elif echo $machine | grep -E -q 'mips64'; then
39 elif echo $machine | grep -E -q 'i[3-6]86'; then
42 echo "Unsupported machine type $machine"
47 if ! [ -f "$OLDDIR/tool/plugson.tar.xz" ]; then
48 echo "Please run under the correct directory!"
52 echo "############# VentoyPlugson $* [$TOOLDIR] ################" >> .
/VentoyPlugson.log
53 date >> .
/VentoyPlugson.log
55 echo "decompress tools" >> .
/VentoyPlugson.log
58 ls *.xz
> /dev
/null
2>&1
60 [ -f .
/xzcat
] && chmod +x .
/xzcat
62 for file in $(ls *.xz); do
63 echo "decompress $file" >> .
/VentoyPlugson.log
64 xzcat
$file > ${file%.xz}
65 [ -f .
/${file%.xz} ] && chmod +x .
/${file%.xz}
66 [ -f .
/$file ] && rm -f .
/$file
71 chmod +x
-R .
/tool
/$TOOLDIR
73 if ! [ -f "$OLDDIR/tool/$TOOLDIR/Plugson" ]; then
74 echo "$OLDDIR/tool/$TOOLDIR/Plugson does not exist!"
79 PATH
=.
/tool
/$TOOLDIR:$PATH
85 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
88 elif [ "$1" = "-H" ]; then
90 if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
93 echo "Invalid host $1"
96 elif [ "$1" = "-P" ]; then
98 if [ $1 -gt 0 -a $1 -le 65535 ]; then
101 echo "Invalid port $1"
111 if [ -z "$DISK" ]; then
116 if ps
-ef | grep "tool/$TOOLDIR/Plugson.*$HOST.*$PORT" | grep -q -v grep; then
117 echo "Another ventoy server is running now, please close it first."
121 if echo $DISK | grep -q "[a-z]d[a-z][1-9]"; then
125 if echo $DISK | grep -E -q "/dev/nvme|/dev/mmcblk/dev/nbd"; then
126 if echo $DISK | grep -q "p[1-9]$"; then
132 if [ ! -b "$DISK" ]; then
133 echo "$DISK does NOT exist."
138 version
=$(get_disk_ventoy_version $DISK)
139 if [ $?
-eq 0 ]; then
140 echo "Ventoy version in Disk: $version"
142 vtPart1Type
=$(dd if=$DISK bs=1 count=1 skip=450 status=none | hexdump -n1 -e '1/1 "%02X"')
143 if [ "$vtPart1Type" = "EE" ]; then
144 echo "Disk Partition Style : GPT"
147 echo "Disk Partition Style : MBR"
151 if check_disk_secure_boot
$DISK; then
152 echo "Secure Boot Support : YES"
155 echo "Secure Boot Support : NO"
159 echo "$DISK is NOT Ventoy disk."
163 PART1
=$(get_disk_part_name $DISK 1)
165 if grep -q "^$PART1 " /proc
/mounts
; then
166 mtpnt
=$(grep "^$PART1 " /proc/mounts | awk '{print $2}' | sed 's/\\040/ /g')
167 fstype
=$(grep "^$PART1 " /proc/mounts | awk '{print $3}')
169 if echo $fstype | grep -q -i 'fuse'; then
170 if hexdump -C -n 16 $PART1 | grep -q -i "EXFAT"; then
172 elif hexdump -C -n 16 $PART1 | grep -q -i "NTFS"; then
177 echo "$PART1 is mounted at $mtpnt $fstype"
179 echo "$PART1 is NOT mounted, please mount it first!"
183 if [ -d "$mtpnt/ventoy" ]; then
184 echo "ventoy directory exist OK"
186 echo "create ventoy directory"
187 mkdir -p "$mtpnt/ventoy"
188 if [ -d "$mtpnt/ventoy" ]; then
189 chmod -R 0755 "$mtpnt/ventoy"
191 echo "Failed to create directory $mtpnt/ventoy"
197 #change current directory to Ventoy disk
199 "$OLDDIR/tool/$TOOLDIR/Plugson" "$HOST" "$PORT" "$OLDDIR" "$DISK" $version "$fstype" $partstyle $secureboot &
203 if [ -f /proc
/$wID/maps
]; then
205 echo "==============================================================="
206 if [ "$LANG" = "zh_CN.UTF-8" ]; then
207 echo " Ventoy Plugson Server 已经启动 ..."
208 echo " 请打开浏览器,访问 http://${HOST}:${PORT}"
210 echo " Ventoy Plugson Server is running ..."
211 echo " Please open your browser and visit http://${HOST}:${PORT}"
213 echo "==============================================================="
215 echo "################## Press Ctrl + C to exit #####################"
222 if [ -n "$OLDDIR" ]; then
224 if [ "$CURDIR" != "$OLDDIR" ]; then