Add uninstall confirm dialog

This commit is contained in:
Teddysun 2014-05-30 10:15:43 +08:00
parent 3f446c9b94
commit 8f5359c0d8

View File

@ -189,27 +189,34 @@ function install(){
# Uninstall Shadowsocks-nodejs # Uninstall Shadowsocks-nodejs
function uninstall_shadowsocks_nodejs(){ function uninstall_shadowsocks_nodejs(){
NODE_PID=`ps -ef | grep -v grep | grep -v ps | grep -i '/usr/local/bin/ssserver' | awk '{print $2}'` printf "Are you sure uninstall Shadowsocks-nodejs? (y/n) : "
if [ ! -z $NODE_PID ]; then read answer
for pid in $NODE_PID printf "\n"
do if [ "$answer" = "y" ]; then
kill -9 $pid NODE_PID=`ps -ef | grep -v grep | grep -v ps | grep -i '/usr/local/bin/ssserver' | awk '{print $2}'`
if [ $? -eq 0 ]; then if [ ! -z $NODE_PID ]; then
echo "Shadowsocks-nodejs process[$pid] has been killed" for pid in $NODE_PID
fi do
done kill -9 $pid
if [ $? -eq 0 ]; then
echo "Shadowsocks-nodejs process[$pid] has been killed"
fi
done
fi
# delete config file
rm -f /etc/shadowsocks.json
cd /usr/local/lib/node_modules/
npm uninstall shadowsocks
rm -f /usr/local/bin/sslocal
rm -f /usr/local/bin/ssserver
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
echo "Shadowsocks-nodejs uninstall success!"
else
echo "uninstall cancelled, Nothing to do"
fi fi
# delete config file
rm -f /etc/shadowsocks.json
cd /usr/local/lib/node_modules/
npm uninstall shadowsocks
rm -f /usr/local/bin/sslocal
rm -f /usr/local/bin/ssserver
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
echo "Shadowsocks-nodejs uninstall success!"
} }
# Initialization step # Initialization step