mirror of
				https://github.com/ventoy/Ventoy.git
				synced 2025-10-31 14:56:22 +00:00 
			
		
		
		
	The changes enable the execution of VentoyWeb.sh by specifying the full path to the file, eliminating the need to be in the Ventoy directory
This commit is contained in:
		| @@ -1,4 +1,4 @@ | |||||||
| #!/bin/bash | #!/usr/bin/env bash | ||||||
|  |  | ||||||
| print_usage() { | print_usage() { | ||||||
|     echo 'Usage:  VentoyWeb.sh [ OPTION ]' |     echo 'Usage:  VentoyWeb.sh [ OPTION ]' | ||||||
| @@ -21,8 +21,6 @@ if [ $uid -ne 0 ]; then | |||||||
|     exit 1 |     exit 1 | ||||||
| fi | fi | ||||||
|  |  | ||||||
| OLDDIR=$(pwd) |  | ||||||
|  |  | ||||||
| if uname -m | grep -E -q 'aarch64|arm64'; then | if uname -m | grep -E -q 'aarch64|arm64'; then | ||||||
|     TOOLDIR=aarch64 |     TOOLDIR=aarch64 | ||||||
| elif uname -m | grep -E -q 'x86_64|amd64'; then | elif uname -m | grep -E -q 'x86_64|amd64'; then | ||||||
| @@ -33,16 +31,13 @@ else | |||||||
|     TOOLDIR=i386 |     TOOLDIR=i386 | ||||||
| fi | fi | ||||||
|  |  | ||||||
| if [ ! -f ./tool/$TOOLDIR/V2DServer ]; then | WORKDIR="$(dirname "$(readlink -f $0)")" | ||||||
|     if [ -f ${0%VentoyWeb.sh}/tool/$TOOLDIR/V2DServer ]; then | PATH=$WORKDIR/tool/$TOOLDIR:$PATH | ||||||
|         cd ${0%VentoyWeb.sh} |  | ||||||
|     fi |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| PATH=./tool/$TOOLDIR:$PATH | pushd $WORKDIR > /dev/null 2>&1 | ||||||
|  |  | ||||||
| if [ ! -f ./boot/boot.img ]; then | if [ ! -f $WORKDIR/boot/boot.img ]; then | ||||||
|     if [ -d ./grub ]; then |     if [ -d $WORKDIR/grub ]; then | ||||||
|         echo "Don't run VentoyWeb.sh here, please download the released install package, and run the script in it." |         echo "Don't run VentoyWeb.sh here, please download the released install package, and run the script in it." | ||||||
|     else |     else | ||||||
|         echo "Current directory is $PWD" |         echo "Current directory is $PWD" | ||||||
| @@ -70,6 +65,12 @@ while [ -n "$1" ]; do | |||||||
|         shift |         shift | ||||||
|         if [ $1 -gt 0 -a $1 -le 65535 ]; then |         if [ $1 -gt 0 -a $1 -le 65535 ]; then | ||||||
|             PORT="$1" |             PORT="$1" | ||||||
|  |             PORT_USED_PID=$(lsof -t -i:$PORT -P -n) | ||||||
|  |  | ||||||
|  |             if [ -n "$PORT_USED_PID" ]; then | ||||||
|  |                 print_err "The port $PORT is currently in use by the process with PID $PORT_USED_PID" | ||||||
|  |                 exit 1 | ||||||
|  |             fi | ||||||
|         else |         else | ||||||
|             print_err "Invalid port $1" |             print_err "Invalid port $1" | ||||||
|             exit 1 |             exit 1 | ||||||
| @@ -85,7 +86,7 @@ if ps -ef | grep "V2DServer.*$HOST.*$PORT" | grep -q -v grep; then | |||||||
|     exit 1 |     exit 1 | ||||||
| fi | fi | ||||||
|  |  | ||||||
| LOGFILE=log.txt | LOGFILE=$WORKDIR/log.txt | ||||||
| #delete the log.txt if it's more than 8MB | #delete the log.txt if it's more than 8MB | ||||||
| if [ -f $LOGFILE ]; then | if [ -f $LOGFILE ]; then | ||||||
|     logsize=$(stat -c '%s' $LOGFILE) |     logsize=$(stat -c '%s' $LOGFILE) | ||||||
| @@ -95,9 +96,9 @@ if [ -f $LOGFILE ]; then | |||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
| if [ -f ./tool/$TOOLDIR/V2DServer.xz ]; then | if [ -f $WORKDIR/tool/$TOOLDIR/V2DServer.xz ]; then | ||||||
|     xz -d ./tool/$TOOLDIR/V2DServer.xz |     xz -d $WORKDIR/tool/$TOOLDIR/V2DServer.xz | ||||||
|     chmod +x ./tool/$TOOLDIR/V2DServer |     chmod +x $WORKDIR/tool/$TOOLDIR/V2DServer | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -105,7 +106,7 @@ V2DServer "$HOST" "$PORT" & | |||||||
| wID=$! | wID=$! | ||||||
| sleep 1 | sleep 1 | ||||||
|  |  | ||||||
| vtVer=$(cat ventoy/version) | vtVer=$(cat $WORKDIR/ventoy/version) | ||||||
| echo "" | echo "" | ||||||
| echo "===============================================================" | echo "===============================================================" | ||||||
| if [ "$LANG" = "zh_CN.UTF-8" ]; then | if [ "$LANG" = "zh_CN.UTF-8" ]; then | ||||||
| @@ -122,9 +123,4 @@ echo "" | |||||||
|  |  | ||||||
| wait $wID | wait $wID | ||||||
|  |  | ||||||
| if [ -n "$OLDDIR" ]; then  | popd $WORKDIR > /dev/null 2>&1 | ||||||
|     CURDIR=$(pwd) |  | ||||||
|     if [ "$CURDIR" != "$OLDDIR" ]; then |  | ||||||
|         cd "$OLDDIR" |  | ||||||
|     fi |  | ||||||
| fi |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user