-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.sh
78 lines (69 loc) · 2.12 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
function deploy_server() {
# download ssprobe-server and config.yaml if not exists
if [ ! -f ssprobe-server ] || [ ! -f config.yaml ]; then
wget -O ssprobe-server https://download.onezol.com/public/ssprobe/ssprobe-server
wget -O config.yaml https://download.onezol.com/public/ssprobe/config.yaml
chmod +x ssprobe-server
clear
fi
# kill ssprobe-server process if exists
kill_if_exist ssprobe-server
# run ssprobe-server
nohup ./ssprobe-server >ssprobe.log 2>&1 &
echo "----------------------------------------------------"
echo "ssprobe-server is running, please check ssprobe.log"
echo "started with pid: $!"
echo "open http://127.0.0.1:10240 in browser"
echo "----------------------------------------------------"
}
function deploy_client() {
# download ssprobe-client if not exists
if [ ! -f ssprobe-client ]; then
wget -O ssprobe-client https://download.onezol.com/public/ssprobe/ssprobe-client
chmod +x ssprobe-client
clear
fi
# kill ssprobe-client process if exists
kill_if_exist ssprobe-client
# read variables from console
read -p "node name: " name
read -p "server address[127.0.0.1]: " server
read -p "server port[3384]: " port
read -p "token[123456]: " token
# default settings
if [ -z "$name" ]; then
name=$(hostname)
fi
if [ -z "$server" ]; then
server="127.0.0.1"
fi
if [ -z "$port" ]; then
port="3384"
fi
if [ -z "$token" ]; then
token="123456"
fi
# run ssprobe-client
nohup ./ssprobe-client --name="$name" --server="$server" --port="$port" --token="$token" >ssprobe.log 2>&1 &
echo "----------------------------------------------------"
echo "ssprobe-client is running, please check ssprobe.log"
echo "started with pid: $!"
echo "----------------------------------------------------"
}
# kill process if exists
# param: process name
function kill_if_exist() {
for pid in $(pgrep "$1"); do
kill "$pid"
done
}
# choose server or client
read -p "Deploy server[0] or client[1]? " option
if [ "$option" -eq 0 ]; then
deploy_server
elif [ "$option" -eq 1 ]; then
deploy_client
else
echo "Invalid option"
fi