4 echo 'Usage: VentoyWebDeepin.sh [ OPTION ]'
5 echo ' OPTION: (optional)'
6 echo ' -H x.x.x.x http server IP address (default is 127.0.0.1)'
7 echo ' -p PORT http server PORT (default is 24680)'
8 echo ' -h print this help'
21 if [ -n "$name" -a "$name" != "root" ]; then
26 if [ -n "$name" -a "$name" != "root" ]; then
33 if [ $uid -ne 0 ]; then
39 if uname
-m | egrep -q 'aarch64|arm64'; then
41 elif uname
-m | egrep -q 'x86_64|amd64'; then
43 elif uname
-m | egrep -q 'mips64'; then
49 if [ ! -f .
/tool
/$TOOLDIR/V2DServer
]; then
50 if [ -f ${0%VentoyWebDeepin.sh}/tool
/$TOOLDIR/V2DServer
]; then
51 cd ${0%VentoyWebDeepin.sh}
55 PATH
=.
/tool
/$TOOLDIR:$PATH
57 if [ ! -f .
/boot
/boot.img
]; then
58 if [ -d .
/grub
]; then
59 echo "Don't run VentoyWebDeepin.sh here, please download the released install package, and run the script in it."
61 echo "Please run under the correct directory!"
70 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
73 elif [ "$1" = "-H" ]; then
75 if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
78 print_err
"Invalid host $1"
81 elif [ "$1" = "-p" ]; then
83 if [ $1 -gt 0 -a $1 -le 65535 ]; then
86 print_err
"Invalid port $1"
95 if ps
-ef | grep "V2DServer.*$HOST.*$PORT" | grep -q -v grep; then
96 print_err
"Another ventoy server is running now, please close it first."
103 if [ -e $LOGFILE ]; then
104 chown
$VUSER $LOGFILE
106 su
$VUSER -c "touch $LOGFILE"
109 #delete the log.txt if it's more than 8MB
110 if [ -f $LOGFILE ]; then
111 logsize
=$(stat -c '%s' $LOGFILE)
112 if [ $logsize -gt 8388608 ]; then
118 if [ -f .
/tool
/$TOOLDIR/V2DServer.xz
]; then
119 xz
-d .
/tool
/$TOOLDIR/V2DServer.xz
120 chmod +x .
/tool
/$TOOLDIR/V2DServer
124 vtWebTmpDir
=$(mktemp -d -p ./ --suffix=_VTMPDIR)
125 chown
$VUSER $vtWebTmpDir
128 V2DServer
"$HOST" "$PORT" &
132 su
$VUSER -c "browser --window-size=550,400 --app=\"http://${HOST}:${PORT}/index.html?chrome-app\" --user-data-dir=$vtWebTmpDir >> $LOGFILE 2>&1" &
138 [ -d /proc
/$V2DPid ] && kill -2 $V2DPid
139 [ -d /proc
/$WebPid ] && kill -9 $WebPid
142 curPid
=$(ps -ef | grep -m1 "$vtWebTmpDir" | egrep -v '\sgrep\s' | awk '{print $2}')
143 if [ -z "$curPid" ]; then
147 if [ -d /proc
/$curPid ]; then
152 [ -d $vtWebTmpDir ] && rm -rf $vtWebTmpDir
154 if [ -n "$OLDDIR" ]; then
156 if [ "$CURDIR" != "$OLDDIR" ]; then
164 trap vtoy_trap_exit HUP INT QUIT TSTP
168 vtVer
=$(cat ventoy/version)
170 echo "=================================================="
171 if [ "$LANG" = "zh_CN.UTF-8" ]; then
172 echo " Ventoy Server $vtVer 已经启动 ..."
174 echo " Ventoy Server $vtVer is running ..."
176 echo "=================================================="
178 echo "########### Press Ctrl + C to exit ###############"
183 [ -d /proc
/$V2DPid ] && kill -2 $V2DPid
185 [ -d $vtWebTmpDir ] && rm -rf $vtWebTmpDir
187 if [ -n "$OLDDIR" ]; then
189 if [ "$CURDIR" != "$OLDDIR" ]; then