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