From eec2952223833cb65d2f277525d630c6b086a0f1 Mon Sep 17 00:00:00 2001 From: Teddysun Date: Tue, 27 May 2014 16:53:44 +0800 Subject: [PATCH] Fix run on start up problem --- shadowsocks.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shadowsocks.sh b/shadowsocks.sh index 9ee4ab7..fe7cc87 100644 --- a/shadowsocks.sh +++ b/shadowsocks.sh @@ -137,6 +137,7 @@ function install(){ if [ -f /usr/bin/ssserver ]; then # Run shadowsocks in the background nohup ssserver -c /etc/config.json > /dev/null 2>&1 & + sleep 1 # Run success or not ps -ef | grep -v grep | grep -v ps | grep -i '/usr/bin/python /usr/bin/ssserver' > /dev/null 2>&1 if [ $? -eq 0 ]; then @@ -147,7 +148,8 @@ function install(){ # Add run on system start up cat /etc/rc.d/rc.local | grep 'ssserver' > /dev/null 2>&1 if [ $? -ne 0 ]; then - echo "nohup ssserver -c /etc/config.json > /dev/null 2>&1 &" >> /etc/rc.d/rc.local + cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak + echo "nohup /usr/bin/python /usr/bin/ssserver -c /etc/config.json > /dev/null 2>&1 &" >> /etc/rc.d/rc.local fi else echo "" @@ -188,6 +190,10 @@ function uninstall_shadowsocks(){ fi # delete config file rm -f /etc/config.json + if [ -f /etc/rc.d/rc.local.bak ];then + rm -f /etc/rc.d/rc.local + mv /etc/rc.d/rc.local.bak /etc/rc.d/rc.local + fi pip uninstall -y shadowsocks if [ $? -eq 0 ]; then echo "Shadowsocks uninstall success!"