适用于:shadowsocks-libev-3.0.3
#!/bin/sh SHADOWSOCKS_SERVER="/usr/local/shadowsocks-libev/bin/ss-server" SERVER_CONF="/etc/shadowsocks-libev/config.json" RET_VAL=0 check_running() { ps -ef | grep ss-server | grep -v grep if [ $? -ne 0 ]; then return 1 else return 0 fi } ss_start() { if check_running; then #shell if判断 返回0 为真 statusid=`ps -ef | grep ss-server | grep -v grep | awk ‘{print $2}‘` echo ${statusid}" is already running..." return 0 fi nohup $SHADOWSOCKS_SERVER -u -c $SERVER_CONF & if check_running; then echo "Starting shadowsocks success" else "Starting shadowsocks failed" RET_VAL=1 fi } ss_stop() { if check_running; then ps -ef | grep ss-server | grep -v grep | awk ‘{print "kill -9 "$2}‘ | sh echo "Stopping shadowsocks success" else echo "shadowsocks is stopped" RET_VAL=1 fi } ss_restart() { ss_stop ss_start } case $1 in ‘start‘|‘stop‘|‘restart‘) ss_$1 ;; *) "Usage: $0 { start | stop | restart }" RET_VAL=1 ;; esac exit $RET_VAL
时间: 2024-10-13 11:10:51