-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
57 lines (50 loc) · 1.33 KB
/
entrypoint.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
#!/bin/bash
set -e
# default option
ss_dir="/shadowsocks"
config_file="/etc/shadowsocks.json"
# changeConf(name, val)
changeConf() {
echo "Modify configuration [$1] to [$2]"
sed -e 's/\(\s*"'$1'"\s*:\s*\).*\(\s*[,|$]\)/\1'$2'\2/' -i $config_file
}
# changeConf_str(name, str)
changeConf_str() {
changeConf $1 '"'$2'"'
}
# parse arguments
while getopts "d:c:p:k:m:t:o:w:" arg
do
case $arg in
d) ss_dir=$OPTARG
;;
c) config_file=$OPTARG
;;
p) server_port=$OPTARG
changeConf 'server_port' $server_port
;;
k) password=$OPTARG
changeConf_str 'password' $password
;;
m) method=$OPTARG
changeConf_str 'method' $method
;;
t) timeout=$OPTARG
changeConf 'timeout' $timeout
;;
o) obfs=$OPTARG
changeConf_str 'obfs' $obfs
;;
w) workers=$OPTARG
changeConf 'workers' $workers
;;
e) cmds=$OPTARG
;;
?)
echo "unkonwn argument $arg"
exit 1
esac
done
# startup ssh daemon
bash /run.sh &
python $ss_dir/shadowsocks/server.py -c $config_file