]>
glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/VentoyWeb.sh
4 echo 'Usage: VentoyWeb.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 " -n don't start web browser"
9 echo ' -h print this help'
21 $app --help 2>&1 | grep -q "$2"
26 if [ -n "$name" -a "$name" != "root" ]; then
31 if [ -n "$name" -a "$name" != "root" ]; then
39 url
="http://${HOST}:${PORT}/index.html"
41 if check_option
"$app" '[-][-]app='; then
42 su
$VUSER -c "$app --app=$url >> $LOGFILE 2>&1"
43 elif check_option
"$app" '[-][-]new[-]window='; then
44 su
$VUSER -c "$app --new-window $url >> $LOGFILE 2>&1"
46 su
$VUSER -c "$app $url >> $LOGFILE 2>&1"
51 if [ $uid -ne 0 ]; then
52 print_err
"Please use sudo or run the script as root."
58 if uname
-a | egrep -q 'aarch64|arm64'; then
60 elif uname
-a | egrep -q 'x86_64|amd64'; then
66 if [ ! -f .
/tool
/$TOOLDIR/V2DServer
]; then
67 if [ -f ${0%VentoyWeb.sh}/tool
/$TOOLDIR/V2DServer
]; then
72 PATH
=.
/tool
/$TOOLDIR:$PATH
74 if [ ! -f .
/boot
/boot.img
]; then
75 if [ -d .
/grub
]; then
76 echo "Don't run VentoyWeb.sh here, please download the released install package, and run the script in it."
78 echo "Please run under the correct directory!"
87 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
90 elif [ "$1" = "-n" ]; then
92 elif [ "$1" = "-H" ]; then
94 if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
97 print_err
"Invalid host $1"
100 elif [ "$1" = "-p" ]; then
102 if [ $1 -gt 0 -a $1 -le 65535 ]; then
105 print_err
"Invalid port $1"
114 if ps
-ef | grep "V2DServer.*$HOST.*$PORT" | grep -q -v grep; then
115 print_err
"Another ventoy server is running now, please close it first."
121 #delete the log.txt if it's more than 8MB
122 if [ -f $LOGFILE ]; then
123 logsize
=$(stat -c '%s' $LOGFILE)
124 if [ $logsize -gt 8388608 ]; then
126 su
$VUSER -c "touch $LOGFILE"
129 su
$VUSER -c "touch $LOGFILE"
134 if [ -f .
/tool
/$TOOLDIR/V2DServer.xz
]; then
135 xz
-d .
/tool
/$TOOLDIR/V2DServer.xz
136 chmod +x .
/tool
/$TOOLDIR/V2DServer
139 V2DServer
"$HOST" "$PORT" &
141 vtVer
=$(cat ventoy/version)
143 echo "=================================================================="
144 echo " Ventoy Server $vtVer is running at http://${HOST}:${PORT} ..."
145 echo "=================================================================="
147 echo "################ Press Ctrl + C to exit ######################"
150 if [ "$NOWEB" = "1" ]; then
151 echo "Please open your web browser and visit http://${HOST}:${PORT}"
153 if which -a google
-chrome-stable >> $LOGFILE 2>&1; then
154 chromium_proc google
-chrome-stable
155 elif which -a google
-chrome >> $LOGFILE 2>&1; then
156 chromium_proc google
-chrome
157 elif which -a chrome
>> $LOGFILE 2>&1; then
159 elif which -a browser
>> $LOGFILE 2>&1; then
160 chromium_proc browser
161 elif which -a firefox
>> $LOGFILE 2>&1; then
162 su
$VUSER -c "firefox --no-remote \"http://${HOST}:${PORT}/index.html\""
164 echo "Please open your web browser and visit http://${HOST}:${PORT}"
168 if ps
-ef | grep "V2DServer.*$HOST.*$PORT" | grep -q -v grep; then
171 print_err
"Ventoy Server Error! Please check log.txt."
177 if [ -n "$OLDDIR" ]; then
179 if [ "$CURDIR" != "$OLDDIR" ]; then