forked from teddysun/shadowsocks_install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshadowsocksR-manyuser-debian
90 lines (82 loc) · 1.72 KB
/
shadowsocksR-manyuser-debian
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
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
### BEGIN INIT INFO
# Provides: ShadowsocksR
# Required-Start: $network $local_fs $remote_fs
# Required-Stop: $network $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Fast tunnel proxy that helps you bypass firewalls
# Description: A secure socks5 proxy, designed to protect your Internet traffic.
### END INIT INFO
# Author: Teddysun <[email protected]>
name=ShadowsocksR
BIN=/usr/local/shadowsocks/server.py
LOG=/usr/local/shadowsocks/ssserver.log
start(){
ulimit -n 512000 && nohup python $BIN m>> $LOG 2>&1 &
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
echo "$name start success"
else
echo "$name start failed"
fi
}
stop(){
pid=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'`
if [[ ! -z $pid ]]; then
eval $(ps -ef | grep "[0-9] python ${BIN} m" | awk '{print "kill "$2}')
RETVAL=$?
if [ "$RETVAL" = "0" ]; then
echo "$name stop success"
else
echo "$name stop failed"
fi
else
echo "$name is not running"
RETVAL=1
fi
}
status(){
pid=`ps -ef | grep -v grep | grep -i "${BIN}" | awk '{print $2}'`
if [[ -z $pid ]]; then
echo "$name is not running"
RETVAL=1
else
echo "$name is running with PID $pid"
RETVAL=0
fi
}
log(){
tail -f $LOG
}
pull(){
cd /usr/local/shadowsocks
git pull
}
case "$1" in
'start')
start
;;
'stop')
stop
;;
'status')
status
;;
'log')
log
;;
'pull')
pull
;;
'restart')
stop
start
RETVAL=$?
;;
*)
echo "Usage: $0 { start | stop | restart | status | log | pull }"
RETVAL=1
;;
esac
exit $RETVAL