Update shadowsocks-go-debian

This commit is contained in:
Teddysun 2015-03-14 18:08:06 +08:00
parent 374b53e200
commit 63f445f07d

View File

@ -12,9 +12,10 @@
# Short-Description: shadowsocks is a lightweight tunneling proxy # Short-Description: shadowsocks is a lightweight tunneling proxy
### END INIT INFO ### END INIT INFO
# Note: this script requires sudo in order to run shadowsocks as the specified # Author: Teddysun <i@teddysun.com>
# user.
# Daemon
NAME=shadowsocks-go
BIN=/usr/bin/shadowsocks-server BIN=/usr/bin/shadowsocks-server
CONFIG_FILE=/etc/shadowsocks/config.json CONFIG_FILE=/etc/shadowsocks/config.json
PID_DIR=/var/run PID_DIR=/var/run
@ -41,13 +42,13 @@ do_status() {
check_running check_running
case $? in case $? in
0) 0)
echo "shadowsocks-go running with PID $PID" echo "$NAME running with PID $PID"
;; ;;
1) 1)
echo "shadowsocks-go not running, remove PID file $PID_FILE" echo "$NAME not running, remove PID file $PID_FILE"
;; ;;
2) 2)
echo "Could not find PID file $PID_FILE, shadowsocks-go does not appear to be running" echo "Could not find PID file $PID_FILE, $NAME does not appear to be running"
;; ;;
esac esac
return 0 return 0
@ -58,14 +59,14 @@ do_start() {
mkdir $PID_DIR || echo "failed creating PID directory $PID_DIR"; exit 1 mkdir $PID_DIR || echo "failed creating PID directory $PID_DIR"; exit 1
fi fi
if check_running; then if check_running; then
echo "shadowsocks-go already running with PID $PID" echo "$NAME already running with PID $PID"
return 0 return 0
fi fi
if [[ ! -r $CONFIG_FILE ]]; then if [[ ! -r $CONFIG_FILE ]]; then
echo "config file $CONFIG_FILE not found" echo "config file $CONFIG_FILE not found"
return 1 return 1
fi fi
echo "starting shadowsocks-go" echo "starting $NAME"
# sudo will set the group to the primary group of $USER # sudo will set the group to the primary group of $USER
$BIN -c $CONFIG_FILE > /dev/null 2>&1 & $BIN -c $CONFIG_FILE > /dev/null 2>&1 &
PID=$! PID=$!
@ -75,13 +76,13 @@ do_start() {
echo "start failed" echo "start failed"
return 1 return 1
fi fi
echo "shadowsocks-go running with PID $PID" echo "$NAME running with PID $PID"
return 0 return 0
} }
do_stop() { do_stop() {
if check_running; then if check_running; then
echo "stopping shadowsocks-go with PID $PID" echo "stopping $NAME with PID $PID"
kill $PID kill $PID
rm -f $PID_FILE rm -f $PID_FILE
else else