Backup /etc/rc.local before modify

This commit is contained in:
Teddysun 2014-10-31 19:33:04 +08:00
parent 2a70ef55a3
commit 7645cd27dd

View File

@ -130,6 +130,7 @@ function install(){
# Add run on system start up
cat /etc/rc.local | grep 'ss-server' > /dev/null 2>&1
if [ $? -ne 0 ]; then
cp -f /etc/rc.local /etc/rc.local_bak
col=`awk 'END{print NR}' /etc/rc.local`
sed -i ''"$col"'i nohup /usr/local/bin/ss-server -c /etc/shadowsocks/config.json > /dev/null 2>&1 &' /etc/rc.local
fi
@ -187,6 +188,11 @@ function uninstall_shadowsocks_libev(){
fi
done
fi
# restore /etc/rc.local
if [[ -s /etc/rc.local_bak ]]; then
rm -f /etc/rc.local
mv /etc/rc.local_bak /etc/rc.local
fi
# delete config file
rm -rf /etc/shadowsocks
# delete shadowsocks