luci-app-serverchan: sync with upstream source
This commit is contained in:
parent
cc3ae1ab90
commit
d11bf3827c
@ -6,7 +6,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-serverchan
|
||||
PKG_VERSION:=1.37
|
||||
PKG_VERSION:=1.39
|
||||
PKG_RELEASE:=5
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
@ -15,7 +15,7 @@ define Package/$(PKG_NAME)
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
DEPENDS:=+iputils-arping +curl
|
||||
DEPENDS:=+iputils-arping +curl +coreutils +coreutils-nohup
|
||||
TITLE:=LuCI support for serverchan
|
||||
PKGARCH:=all
|
||||
endef
|
||||
@ -28,10 +28,11 @@ define Package/$(PKG_NAME)/conffiles
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d $(1)/usr/bin/serverchan $(1)/etc/config $(1)/usr/lib/lua/luci
|
||||
$(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/uci-defaults $(1)/usr/bin/serverchan $(1)/etc/config $(1)/usr/lib/lua/luci
|
||||
$(CP) ./luasrc/* $(1)/usr/lib/lua/luci
|
||||
$(INSTALL_CONF) ./root/etc/config/serverchan $(1)/etc/config
|
||||
$(INSTALL_BIN) ./root/etc/init.d/serverchan $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./root/etc/uci-defaults/luci-serverchan $(1)/etc/uci-defaults
|
||||
$(INSTALL_BIN) ./root/usr/bin/serverchan/serverchan $(1)/usr/bin/serverchan
|
||||
endef
|
||||
|
||||
|
||||
@ -4,13 +4,34 @@ STOP=10
|
||||
|
||||
|
||||
start() {
|
||||
flag=$(ps | grep "/usr/bin/serverchan/serverchan" | grep -v "grep" | wc -l)
|
||||
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
|
||||
echo "enable"
|
||||
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 &
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
kill -9 `pgrep -f /usr/bin/serverchan/serverchan`
|
||||
kill -9 `pgrep -f serverchan/serverchan`
|
||||
enable=$(uci get serverchan.serverchan.serverchan_enable)
|
||||
if [ $enable -ne 1 ]; then
|
||||
echo 'stop!'
|
||||
kill $(pidof serverchan) >/dev/null 2>&1
|
||||
kill -9 $(ps | grep serverchan | grep -v "grep" | awk '{print $1}') >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
restart(){
|
||||
stop
|
||||
sleep 1
|
||||
start
|
||||
echo "restarted."
|
||||
}
|
||||
|
||||
@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
touch /etc/config/serverchan
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@serverchan[-1]
|
||||
add ucitrack serverchan
|
||||
set ucitrack.@serverchan[-1].init=serverchan
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@ -38,9 +38,9 @@ function read_config(){
|
||||
temperature=`get_config temperature`
|
||||
device_name=`get_config device_name`
|
||||
dir="/tmp/serverchan/"
|
||||
up_timeout=`get_config uptimeout`
|
||||
up_timeout=`get_config up_timeout`
|
||||
if [ -z "$up_timeout" ] ; then up_timeout="2";fi
|
||||
down_timeout=`get_config uptimeout`
|
||||
down_timeout=`get_config down_timeout`
|
||||
if [ -z "$down_timeout" ] ; then down_timeout="10";fi
|
||||
}
|
||||
|
||||
@ -901,15 +901,15 @@ function rand_geturl(){
|
||||
cpu_fuzai=`cat /proc/loadavg | awk '{print $1}' 2>/dev/null`
|
||||
cpuload=`get_config cpuload`
|
||||
if [ ! -z "$cpu_fuzai" ] && [ ! -z "$cpuload" ] && [ `expr $cpu_fuzai \> $cpuload` -eq "1" ] ; then
|
||||
if [ -f ${logfile} ] && [ $(grep -c "" ${logfile}) -ge "2" ] ; then
|
||||
log_end=`awk '{print}' ${logfile} | tail -n 2 | awk 'NR==1'`
|
||||
log_end_2=`awk 'END {print}' ${logfile}`
|
||||
if ( echo ${log_end} | grep -q "负载" ) && ( echo ${log_end_2} | grep -q "负载" ) ; then
|
||||
sed -i '$d' -i /tmp/serverchan/serverchan.log
|
||||
sed -i '$d' -i /tmp/serverchan/serverchan.log
|
||||
echo "`echo $log_end | awk '{print $1" "$2}'` 【刷屏日志自动过滤】 CPU 负载持续超高: `echo $log_end | awk '{print $6}'`" >> ${logfile}
|
||||
fi
|
||||
fi
|
||||
#if [ -f ${logfile} ] && [ $(grep -c "" ${logfile}) -ge "2" ] ; then
|
||||
#log_end=`awk '{print}' ${logfile} | tail -n 2 | awk 'NR==1'`
|
||||
#log_end_2=`awk 'END {print}' ${logfile}`
|
||||
#if ( echo ${log_end} | grep -q "负载" ) && ( echo ${log_end_2} | grep -q "负载" ) ; then
|
||||
#sed -i '$d' -i /tmp/serverchan/serverchan.log
|
||||
#sed -i '$d' -i /tmp/serverchan/serverchan.log
|
||||
#echo "`echo $log_end | awk '{print $1" "$2}'` 【刷屏日志自动过滤】 CPU 负载持续超高: `echo $log_end | awk '{print $6}'`" >> ${logfile}
|
||||
#fi
|
||||
#fi
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!警报!!】 CPU 负载过高: ${cpu_fuzai}" >> ${logfile}
|
||||
elif [ -z "$cpu_fuzai" ] ; then
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法读取设备负载,请检查命令" >> ${logfile}
|
||||
@ -943,15 +943,15 @@ function rand_geturl(){
|
||||
cpu_wendu=`soc_temp`
|
||||
temperature=`get_config temperature`
|
||||
if [ ! -z "$cpu_wendu" ] && [ ! -z "$temperature" ] && [ "$cpu_wendu" -gt "$temperature" ] ; then
|
||||
if [ -f ${logfile} ] && [ $(grep -c "" ${logfile}) -ge "2" ] ; then
|
||||
log_end=`awk '{print}' ${logfile} | tail -n 2 | awk 'NR==1'`
|
||||
log_end_2=`awk 'END {print}' ${logfile}`
|
||||
if ( echo ${log_end} | grep -q "温度" ) && ( echo ${log_end_2} | grep -q "温度" ) ; then
|
||||
sed -i '$d' -i /tmp/serverchan/serverchan.log
|
||||
sed -i '$d' -i /tmp/serverchan/serverchan.log
|
||||
echo "`echo $log_end | awk '{print $1" "$2}'` 【刷屏日志自动过滤】 CPU 温度持续超高: `echo $log_end | awk '{print $6}'`" >> ${logfile}
|
||||
fi
|
||||
fi
|
||||
#if [ -f ${logfile} ] && [ $(grep -c "" ${logfile}) -ge "2" ] ; then
|
||||
#log_end=`awk '{print}' ${logfile} | tail -n 2 | awk 'NR==1'`
|
||||
#log_end_2=`awk 'END {print}' ${logfile}`
|
||||
#if ( echo ${log_end} | grep -q "温度" ) && ( echo ${log_end_2} | grep -q "温度" ) ; then
|
||||
#sed -i '$d' -i /tmp/serverchan/serverchan.log
|
||||
#sed -i '$d' -i /tmp/serverchan/serverchan.log
|
||||
#echo "`echo $log_end | awk '{print $1" "$2}'` 【刷屏日志自动过滤】 CPU 温度持续超高: `echo $log_end | awk '{print $6}'`" >> ${logfile}
|
||||
#fi
|
||||
#fi
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!警报!!】 CPU 温度过高: ${cpu_wendu}" >> ${logfile}
|
||||
elif [ -z "$cpu_wendu" ] ; then
|
||||
echo "`date "+%Y-%m-%d %H:%M:%S"` 【!!!】无法读取设备温度,请检查命令" >> ${logfile}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user