luci-app-serverchan: sync with upstream source

This commit is contained in:
CN_SZTL 2020-03-03 15:30:34 +08:00
parent 2aadd09b9f
commit bcbb49f778
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
2 changed files with 26 additions and 19 deletions

View File

@ -4,27 +4,20 @@ START=99
STOP=10
start() {
flag=$(ps | grep "serverchan/serverchan" | grep -v "grep" | wc -l)
if [ $flag -eq 0 ] ;then
/usr/bin/serverchan/serverchan &
else
/usr/bin/serverchan/serverchan crontab
fi
enable=$(uci get serverchan.serverchan.serverchan_enable)
if [ $enable -eq 1 ]; then
kill -9 $(ps | grep serverchan/serverchan | grep -v "grep" | awk '{print $1}') >/dev/null 2>&1
sleep 1
nohup /usr/bin/serverchan/serverchan 2>&1 &
/usr/bin/serverchan/serverchan &
echo "serverchan is starting now ..."
else
/usr/bin/serverchan/serverchan crontab
echo "serverchan is not enable, detect crontab and exit ..."
stop
fi
}
stop() {
kill -9 `pgrep -f serverchan/serverchan`
enable=$(uci get serverchan.serverchan.serverchan_enable)
if [ $enable -ne 1 ]; then
kill $(pidof serverchan) >/dev/null 2>&1
kill -9 $(ps | grep serverchan | grep -v "grep" | awk '{print $1}') >/dev/null 2>&1
fi
kill -9 `pgrep -f "/usr/bin/serverchan/serverchan"` 2>/dev/null
echo "serverchan exit ..."
}
restart(){

View File

@ -123,7 +123,13 @@ function serverchan_cron(){
if ( echo `crontab -l` | grep -q "serverchan" ); then
crontab -l > conf && sed -i "/serverchan/d" conf && crontab conf && rm -f conf >/dev/null 2>&1
fi
fi
fi
serverchan_enable=`get_config serverchan_enable`
if [ -z "$serverchan_enable" ] ; then
if ( echo `crontab -l` | grep -q "serverchan" ); then
crontab -l > conf && sed -i "/serverchan/d" conf && crontab conf && rm -f conf >/dev/null 2>&1
fi
fi
/etc/init.d/cron stop
/etc/init.d/cron start
}
@ -439,8 +445,7 @@ function up(){
if [ ! -f "${dir}ipAddress" ] ; then > ${dir}ipAddress;fi
if [ "$1" ] ;then
# 如果 ipAddress 文件中存在此ip则跳过待断线检测
grep -w -q $1 ${dir}ipAddress
if [ $? -ne 0 ] ; then
if ( ! echo ${dir}ipAddress | grep -q -w $1 ) ; then
local ip_mac=`getmac $1`
local ip_name=`getname $1 $ip_mac`
@ -791,7 +796,6 @@ function send(){
fi
uci set serverchan.serverchan.send_enable=0
uci commit serverchan
exit
}
# 初始化在线设备列表
@ -825,6 +829,15 @@ if [ "$1" ] ;then
exit
fi
# 防止重复启动
basePath=$(cd `dirname $0`; pwd)
fullPathProc=$basePath/${0##*/}
pCount=$(ps -ef | grep $fullPathProc | grep -v 'grep' | grep -v ' -c sh' | grep -v $$ | grep -c 'sh')
if [ $pCount -gt 1 ]; then
echo "serverchan is running ..."
exit 0
fi
# 初始化
serverchan_cron
read_config
@ -835,6 +848,7 @@ serverchan_first
while [ "$serverchan_enable" -eq "1" ] ;
do
deltemp
read_config
rand_geturl
usage
# 外网IP变化检测