-
Notifications
You must be signed in to change notification settings - Fork 0
/
shadowsocks-crond.sh
44 lines (39 loc) · 1.65 KB
/
shadowsocks-crond.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
#=================================================================#
# System Required: CentOS, Debian, Ubuntu #
# Description: Check Shadowsocks Server is running or not #
# Author: Teddysun <[email protected]> #
# Visit: https://shadowsocks.be/6.html #
#=================================================================#
name=(Shadowsocks Shadowsocks-Python ShadowsocksR Shadowsocks-Go Shadowsocks-libev)
path=/var/log
[[ ! -d ${path} ]] && mkdir -p ${path}
log=${path}/shadowsocks-crond.log
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
i=0
for init in "${shadowsocks_init[@]}"; do
pid=""
if [ -f ${init} ]; then
ss_status=$(${init} status)
if [ $? -eq 0 ]; then
pid=$(echo "$ss_status" | sed -e 's/[^0-9]*//g')
fi
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') Starting ${name[$i]}" >> ${log}
${init} start &>/dev/null
if [ $? -eq 0 ]; then
echo "$(date +'%Y-%m-%d %H:%M:%S') ${name[$i]} start success" >> ${log}
else
echo "$(date +'%Y-%m-%d %H:%M:%S') ${name[$i]} start failed" >> ${log}
fi
else
echo "$(date +'%Y-%m-%d %H:%M:%S') ${name[$i]} is running with pid $pid" >> ${log}
fi
fi
((i++))
done