update for 4in1 version
This commit is contained in:
parent
0fee300eb9
commit
dab26bb991
|
|
@ -6,51 +6,50 @@
|
||||||
# Visit: https://shadowsocks.be/6.html #
|
# Visit: https://shadowsocks.be/6.html #
|
||||||
#=================================================================#
|
#=================================================================#
|
||||||
|
|
||||||
# name
|
name=(Shadowsocks Shadowsocks-Python ShadowsocksR Shadowsocks-Go Shadowsocks-libev)
|
||||||
name=Shadowsocks
|
|
||||||
# log path
|
|
||||||
path=/var/log
|
path=/var/log
|
||||||
# check log path
|
|
||||||
[[ ! -d ${path} ]] && mkdir -p ${path}
|
[[ ! -d ${path} ]] && mkdir -p ${path}
|
||||||
# log file
|
|
||||||
log=${path}/shadowsocks-crond.log
|
log=${path}/shadowsocks-crond.log
|
||||||
# shadowsocks-python path(centos)
|
|
||||||
shadowsocks[0]=/usr/bin/ssserver
|
shadowsocks[0]=/usr/bin/ssserver
|
||||||
# shadowsocks-python path(debian)
|
|
||||||
shadowsocks[1]=/usr/local/bin/ssserver
|
shadowsocks[1]=/usr/local/bin/ssserver
|
||||||
# shadowsocks-go path
|
|
||||||
shadowsocks[2]=/usr/bin/shadowsocks-server
|
shadowsocks[2]=/usr/bin/shadowsocks-server
|
||||||
# shadowsocks-libev path
|
|
||||||
shadowsocks[3]=/usr/local/bin/ss-server
|
shadowsocks[3]=/usr/local/bin/ss-server
|
||||||
# shadowsocksR path
|
|
||||||
shadowsocks[4]=/usr/local/shadowsocks/server.py
|
shadowsocks[4]=/usr/local/shadowsocks/server.py
|
||||||
# default pid value
|
|
||||||
pid=""
|
|
||||||
|
|
||||||
[ ! -f /etc/init.d/shadowsocks ] && echo "`date +"%Y-%m-%d %H:%M:%S"` /etc/init.d/shadowsocks is not existed" >> ${log} && exit
|
shadowsocks_init[0]=/etc/init.d/shadowsocks
|
||||||
|
shadowsocks_init[1]=/etc/init.d/shadowsocks-python
|
||||||
|
shadowsocks_init[2]=/etc/init.d/shadowsocks-r
|
||||||
|
shadowsocks_init[3]=/etc/init.d/shadowsocks-go
|
||||||
|
shadowsocks_init[4]=/etc/init.d/shadowsocks-libev
|
||||||
|
|
||||||
# check Shadowsocks status
|
i=0
|
||||||
/etc/init.d/shadowsocks status &>/dev/null
|
for init in ${shadowsocks_init[@]}; do
|
||||||
if [ $? -eq 0 ]; then
|
pid=""
|
||||||
for bin in ${shadowsocks[*]}
|
if [ -f ${init} ]; then
|
||||||
do
|
${init} status &>/dev/null
|
||||||
pid=`ps -ef | grep -v grep | grep -i "${bin}" | awk '{print $2}'`
|
if [ $? -eq 0 ]; then
|
||||||
if [ ! -z ${pid} ]; then
|
for bin in ${shadowsocks[@]}; do
|
||||||
break
|
pid=`ps -ef | grep -v grep | grep -i "${bin}" | awk '{print $2}'`
|
||||||
|
if [ ! -z ${pid} ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check status & auto start
|
if [ -z ${pid} ]; then
|
||||||
if [ -z ${pid} ]; then
|
echo "`date +"%Y-%m-%d %H:%M:%S"` ${name[$i]} is not running" >> ${log}
|
||||||
echo "`date +"%Y-%m-%d %H:%M:%S"` $name is not running" >> ${log}
|
echo "`date +"%Y-%m-%d %H:%M:%S"` Starting ${name[$i]}" >> ${log}
|
||||||
echo "`date +"%Y-%m-%d %H:%M:%S"` Starting $name" >> ${log}
|
${init} start &>/dev/null
|
||||||
/etc/init.d/shadowsocks start &>/dev/null
|
if [ $? -eq 0 ]; then
|
||||||
if [ $? -eq 0 ]; then
|
echo "`date +"%Y-%m-%d %H:%M:%S"` ${name[$i]} start success" >> ${log}
|
||||||
echo "`date +"%Y-%m-%d %H:%M:%S"` $name start success" >> ${log}
|
else
|
||||||
else
|
echo "`date +"%Y-%m-%d %H:%M:%S"` ${name[$i]} start failed" >> ${log}
|
||||||
echo "`date +"%Y-%m-%d %H:%M:%S"` $name start failed" >> ${log}
|
fi
|
||||||
|
else
|
||||||
|
echo "`date +"%Y-%m-%d %H:%M:%S"` ${name[$i]} is running with pid $pid" >> ${log}
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
else
|
((i++))
|
||||||
echo "`date +"%Y-%m-%d %H:%M:%S"` $name is running with pid $pid" >> ${log}
|
done
|
||||||
fi
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user