]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - INSTALL/VentoyWebDeepin.sh
script optimization for UOS
[Ventoy.git] / INSTALL / VentoyWebDeepin.sh
1 #!/bin/sh
2
3 print_usage() {
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'
9 echo ''
10 }
11
12 print_err() {
13 echo ""
14 echo "$*"
15 echo ""
16 }
17
18 get_user() {
19 name=$(logname)
20 if [ -n "$name" -a "$name" != "root" ]; then
21 echo $name; return
22 fi
23
24 name=${HOME#/home/}
25 if [ -n "$name" -a "$name" != "root" ]; then
26 echo $name; return
27 fi
28 }
29
30 uid=$(id -u)
31 if [ $uid -ne 0 ]; then
32 exec sudo sh $0 $*
33 fi
34
35 OLDDIR=$(pwd)
36
37 if uname -m | egrep -q 'aarch64|arm64'; then
38 TOOLDIR=aarch64
39 elif uname -m | egrep -q 'x86_64|amd64'; then
40 TOOLDIR=x86_64
41 elif uname -m | egrep -q 'mips64'; then
42 TOOLDIR=mips64el
43 else
44 TOOLDIR=i386
45 fi
46
47 if [ ! -f ./tool/$TOOLDIR/V2DServer ]; then
48 if [ -f ${0%VentoyWebDeepin.sh}/tool/$TOOLDIR/V2DServer ]; then
49 cd ${0%VentoyWebDeepin.sh}
50 fi
51 fi
52
53 PATH=./tool/$TOOLDIR:$PATH
54
55 if [ ! -f ./boot/boot.img ]; then
56 if [ -d ./grub ]; then
57 echo "Don't run VentoyWebDeepin.sh here, please download the released install package, and run the script in it."
58 else
59 echo "Please run under the correct directory!"
60 fi
61 exit 1
62 fi
63
64 HOST="127.0.0.1"
65 PORT=24680
66
67 while [ -n "$1" ]; do
68 if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
69 print_usage
70 exit 0
71 elif [ "$1" = "-H" ]; then
72 shift
73 if echo $1 | grep -q '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'; then
74 HOST="$1"
75 else
76 print_err "Invalid host $1"
77 exit 1
78 fi
79 elif [ "$1" = "-p" ]; then
80 shift
81 if [ $1 -gt 0 -a $1 -le 65535 ]; then
82 PORT="$1"
83 else
84 print_err "Invalid port $1"
85 exit 1
86 fi
87 fi
88
89 shift
90 done
91
92
93 if ps -ef | grep "V2DServer.*$HOST.*$PORT" | grep -q -v grep; then
94 print_err "Another ventoy server is running now, please close it first."
95 exit 1
96 fi
97
98 if grep -q -i uos /etc/os-release; then
99 . ./tool/WebUos.sh
100 else
101 . ./tool/WebDeepin.sh
102 fi