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
32 if uos
-browser --version > /dev
/null
2>&1; then
33 echo "uos-browser"; return
40 if [ $uid -ne 0 ]; then
46 if uname
-m | egrep -q 'aarch64|arm64'; then
48 elif uname
-m | egrep -q 'x86_64|amd64'; then
50 elif uname
-m | egrep -q 'mips64'; then
56 if [ ! -f .
/tool
/$TOOLDIR/V2DServer
]; then
57 if [ -f ${0%VentoyWebDeepin.sh}/tool
/$TOOLDIR/V2DServer
]; then
58 cd ${0%VentoyWebDeepin.sh}
62 PATH
=.
/tool
/$TOOLDIR:$PATH
64 if [ ! -f .
/boot
/boot.img
]; then
65 if [ -d .
/grub
]; then
66 echo "Don't run VentoyWebDeepin.sh here, please download the released install package, and run the script in it."
68 echo "Please run under the correct directory!"
77 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
80 elif [ "$1" = "-H" ]; then
82 if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
85 print_err
"Invalid host $1"
88 elif [ "$1" = "-p" ]; then
90 if [ $1 -gt 0 -a $1 -le 65535 ]; then
93 print_err
"Invalid port $1"
102 if ps
-ef | grep "V2DServer.*$HOST.*$PORT" | grep -q -v grep; then
103 print_err
"Another ventoy server is running now, please close it first."
110 if [ -e $LOGFILE ]; then
111 LogGroup
=$(stat -c '%G' $LOGFILE)
112 if [ "$LogGroup" = "root" ]; then
114 su
$VUSER -c "touch $LOGFILE"
117 su
$VUSER -c "touch $LOGFILE"
120 #delete the log.txt if it's more than 8MB
121 if [ -f $LOGFILE ]; then
122 logsize
=$(stat -c '%s' $LOGFILE)
123 if [ $logsize -gt 8388608 ]; then
129 if [ -f .
/tool
/$TOOLDIR/V2DServer.xz
]; then
130 xz
-d .
/tool
/$TOOLDIR/V2DServer.xz
131 chmod +x .
/tool
/$TOOLDIR/V2DServer
135 vtWebTmpDir
=$(su $VUSER -c "mktemp -d -p ./ --suffix=_VTMPDIR")
137 V2DServer
"$HOST" "$PORT" &
141 browsercmd
=$(get_browser_cmd)
142 su
$VUSER -c "$browsercmd --window-size=550,400 --app=\"http://${HOST}:${PORT}/index.html?chrome-app\" --user-data-dir=$vtWebTmpDir >> $LOGFILE 2>&1" &
148 [ -d /proc
/$V2DPid ] && kill -2 $V2DPid
149 [ -d /proc
/$WebPid ] && kill -9 $WebPid
152 curPid
=$(ps -ef | grep -m1 "$vtWebTmpDir" | egrep -v '\sgrep\s' | awk '{print $2}')
153 if [ -z "$curPid" ]; then
157 if [ -d /proc
/$curPid ]; then
162 [ -d $vtWebTmpDir ] && rm -rf $vtWebTmpDir
164 if [ -n "$OLDDIR" ]; then
166 if [ "$CURDIR" != "$OLDDIR" ]; then
174 trap vtoy_trap_exit HUP INT QUIT TSTP
178 vtVer
=$(cat ventoy/version)
180 echo "=================================================="
181 if [ "$LANG" = "zh_CN.UTF-8" ]; then
182 echo " Ventoy Server $vtVer 已经启动 ..."
184 echo " Ventoy Server $vtVer is running ..."
186 echo "=================================================="
188 echo "########### Press Ctrl + C to exit ###############"
193 [ -d /proc
/$V2DPid ] && kill -2 $V2DPid
195 [ -d $vtWebTmpDir ] && rm -rf $vtWebTmpDir
197 if [ -n "$OLDDIR" ]; then
199 if [ "$CURDIR" != "$OLDDIR" ]; then