mirror of
https://github.com/sirpdboy/sirpdboy-package.git
synced 2025-01-09 04:17:45 +08:00
up autotimeset 1.9.2
This commit is contained in:
parent
cc236612f8
commit
6a4aed176b
@ -8,8 +8,9 @@ include $(TOPDIR)/rules.mk
|
||||
LUCI_TITLE:=LuCI support for Scheduled Time setting
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_VERSION:=1.9.1
|
||||
PKG_RELEASE:=20230309
|
||||
PKG_VERSION:=1.9.2
|
||||
PKG_RELEASE:=20230519
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/autotimeset
|
||||
|
@ -10,6 +10,15 @@ translate(" <input class=\"cbi-button cbi-button-apply\" type=\
|
||||
translate("Test/Verify Settings") ..
|
||||
" \" onclick=\"window.open('https://tool.lu/crontab/')\"/>"))
|
||||
|
||||
s = m:section(TypedSection, 'global')
|
||||
s.anonymous=true
|
||||
|
||||
e=s:option(TextValue, "customscript")
|
||||
e.description = translate("Only by editing the content of the custom script well and scheduling the custom script task can it be executed effectively.")
|
||||
e.rows = 5
|
||||
e.default = '#!/bin/sh'
|
||||
e.rmempty = false
|
||||
|
||||
s=m:section(TypedSection,"stime","")
|
||||
s.addremove=true
|
||||
s.anonymous=true
|
||||
@ -26,13 +35,14 @@ e:value(7,translate("Scheduled Clearmem"))
|
||||
e:value(8,translate("Scheduled Sysfree"))
|
||||
e:value(9,translate("Scheduled DisReconn"))
|
||||
e:value(10,translate("Scheduled Restartmwan3"))
|
||||
e:value(11,translate("Scheduled Customscript"))
|
||||
e.default=2
|
||||
|
||||
e=s:option(Value,"month",translate("Month(0~11)"))
|
||||
e.rmempty = false
|
||||
e.default = '*'
|
||||
|
||||
week=s:option(ListValue,"week",translate("Week Day(0~6)"))
|
||||
week=s:option(Value,"week",translate("Week Day(0~6)"))
|
||||
week.rmempty = true
|
||||
week:value('*',translate("Everyday"))
|
||||
week:value(0,translate("Sunday"))
|
||||
|
@ -50,6 +50,12 @@ msgstr "定时检测断网重连"
|
||||
msgid "Scheduled Restartmwan3"
|
||||
msgstr "定时检测MWAN3出错重启"
|
||||
|
||||
msgid "Scheduled Customscript"
|
||||
msgstr "定时执行自定义脚本"
|
||||
|
||||
msgid "Only by editing the content of the custom script well and scheduling the custom script task can it be executed effectively."
|
||||
msgstr "编辑好自定义脚本内容,定时自定义脚本任务才能有效执行。"
|
||||
|
||||
msgid "Month(0~11)"
|
||||
msgstr "月份(0~11)"
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
#!/bin/sh
|
@ -1,3 +1,8 @@
|
||||
|
||||
config global
|
||||
option enabled '0'
|
||||
option customscript '#!/bin/sh'
|
||||
|
||||
config stime
|
||||
option hour '*/4'
|
||||
option stype '7'
|
||||
@ -8,11 +13,11 @@ config stime
|
||||
|
||||
config stime
|
||||
option minute '0'
|
||||
option stype '8'
|
||||
option week '1'
|
||||
option hour '5'
|
||||
option month '*'
|
||||
option stype '11'
|
||||
option hour '*/5'
|
||||
option enable '0'
|
||||
option week '1,3,5'
|
||||
|
||||
config stime
|
||||
option week '*'
|
||||
@ -32,17 +37,25 @@ config stime
|
||||
|
||||
config stime
|
||||
option week '*'
|
||||
option minute '0'
|
||||
option stype '3'
|
||||
option hour '3'
|
||||
option month '*'
|
||||
option stype '10'
|
||||
option minute '*/5'
|
||||
option hour '*'
|
||||
option enable '0'
|
||||
|
||||
config stime
|
||||
option week '*'
|
||||
option stype '9'
|
||||
option hour '0'
|
||||
option minute '*/5'
|
||||
option month '*'
|
||||
option enable '0'
|
||||
option hour '*'
|
||||
|
||||
config stime
|
||||
option month '*'
|
||||
option week '*'
|
||||
option hour '0'
|
||||
option enable '0'
|
||||
option stype '10'
|
||||
option minute '*/5'
|
||||
|
||||
|
@ -10,6 +10,14 @@ TMP=/etc/autotimeset
|
||||
run_autotimeset()
|
||||
{
|
||||
ssum=$(grep -c stime /etc/config/autotimeset)
|
||||
|
||||
|
||||
customscript=$(uci -q get autotimeset.@global[0].customscript ) || customscript='#!/bin/sh'
|
||||
script=`echo $customscript | grep '#!/bin/sh'` >/dev/null 2>&1
|
||||
[ $script ] || {
|
||||
echo '#!/bin/sh' >/etc/autotimeset/timesetcustomscript
|
||||
echo $script >>/etc/autotimeset/timesetcustomscript
|
||||
}
|
||||
for i in $(seq 0 $((ssum-1)))
|
||||
do
|
||||
enable=$(uci -q get autotimeset.@stime[$i].enable )
|
||||
@ -20,7 +28,6 @@ do
|
||||
week=$(uci -q get autotimeset.@stime[$i].week ) || week="*"
|
||||
minute=$(uci -q get autotimeset.@stime[$i].minute ) || minute="00"
|
||||
hour=$(uci -q get autotimeset.@stime[$i].hour ) || hour="*"
|
||||
|
||||
[ "x$hour" = "x0" ] && hour="00"
|
||||
[ "x$minute" = "x0" ] && minute="00"
|
||||
case "$stype" in
|
||||
@ -64,6 +71,11 @@ do
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartmwan3"
|
||||
echo "$cmd" >> /etc/crontabs/root
|
||||
;;
|
||||
11)
|
||||
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript"
|
||||
echo $customscript > /etc/autotimeset/timesetcustomscript
|
||||
echo "$cmd" >> /etc/crontabs/root
|
||||
;;
|
||||
esac
|
||||
|
||||
fi
|
||||
|
@ -20,21 +20,18 @@ limit_log() {
|
||||
}
|
||||
|
||||
remwan3() {
|
||||
i=0
|
||||
while [[ $i -lt 3 ]]
|
||||
do
|
||||
|
||||
while true; do
|
||||
status=$(/usr/sbin/mwan3 status | grep error)
|
||||
if [ -z $status ]; then
|
||||
log "Mwan3 is OK"
|
||||
break
|
||||
exit 1
|
||||
else
|
||||
log "mwan3 restarting $i... $status"
|
||||
log "mwan3 restarting ... $status"
|
||||
/usr/sbin/mwan3 restart
|
||||
fi
|
||||
i=$(($i + 1))
|
||||
sleep 30
|
||||
fi
|
||||
sleep 60
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
disreconnwan() {
|
||||
@ -114,6 +111,16 @@ trigger() {
|
||||
restartmwan3)
|
||||
remwan3
|
||||
;;
|
||||
customscript)
|
||||
script=`cat /etc/autotimeset/timesetcustomscript | grep '#!/bin/sh'` >/dev/null 2>&1
|
||||
[ $script ] || {
|
||||
script=` cat /etc/autotimeset/timesetcustomscript `
|
||||
echo '#!/bin/sh' >/etc/autotimeset/timesetcustomscript
|
||||
echo $script >>/etc/autotimeset/timesetcustomscript
|
||||
}
|
||||
source /etc/autotimeset/timesetcustomscript
|
||||
log "CustomScript succeeded!"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user