update 2025-03-31 00:24:10

This commit is contained in:
kenzok8 2025-03-31 00:24:10 +08:00
parent e6633d779a
commit 04ce318b61
33 changed files with 2 additions and 1012 deletions

View File

@ -9,8 +9,8 @@
## 功能说明:
### 任务设置2.2版taskplan
#### 2025.3.19 定时设置2.2为和以前老版本做好区分重命名luci-app-taskplan配适openwrt24.10.
### 任务设置2.2.1taskplan
#### 2025.3.19 任务设置2.2.1为和以前老版本做好区分重命名luci-app-taskplan配适openwrt24.10.
### 定时设置2.0版
#### 2023.5.23 定时设置2.0版:定时执行任务设置和开机启动任务设置二合一版,并增加自定义脚本功能。

View File

@ -1,56 +0,0 @@
local o=require"luci.dispatcher"
local e=require("luci.model.ipkg")
local s=require"nixio.fs"
local e=luci.model.uci.cursor()
local m,s,e
m=Map("autotimeset",translate("Scheduled Setting"),translate("Timing settings include: timing restart, timing shutdown, timing restart network, all functions can be used together."))
s=m:section(TypedSection,"stime","")
s.addremove=true
s.anonymous=true
s.template = "cbi/tblsection"
e=s:option(ListValue,"stype",translate("Scheduled Type"))
e:value(1,translate("Scheduled Reboot"))
e:value(2,translate("Scheduled Poweroff"))
e:value(3,translate("Scheduled ReNetwork"))
e:value(4,translate("Scheduled RestartSamba"))
e:value(5,translate("Scheduled Restartwan"))
e:value(6,translate("Scheduled Closewan"))
e:value(7,translate("Scheduled Clearmem"))
e:value(8,translate("Scheduled Sysfree"))
e:value(9,translate("Scheduled DisReconn"))
e.default=2
week=s:option(ListValue,"week",translate("Week Day"))
week.rmempty = true
week:value('*',translate("Everyday"))
week:value(0,translate("Sunday"))
week:value(1,translate("Monday"))
week:value(2,translate("Tuesday"))
week:value(3,translate("Wednesday"))
week:value(4,translate("Thursday"))
week:value(5,translate("Friday"))
week:value(6,translate("Saturday"))
week.default='*'
e=s:option(Value,"hour",translate("Hour"))
e.datatype = "range(0,23)"
e.rmempty = false
e.default = 4
e=s:option(Value,"minute",translate("Minute"))
e.datatype = "range(0,59)"
e.rmempty = false
e.default = 0
e=s:option(Flag,"enable",translate("Enable"))
e.rmempty = false
e.default=0
m.apply_on_parse = true
m.on_after_apply = function(self,map)
io.popen("/etc/init.d/autotimeset start")
end
return m

View File

@ -1,88 +0,0 @@
local o=require"luci.dispatcher"
local e=require("luci.model.ipkg")
local s=require"nixio.fs"
local e=luci.model.uci.cursor()
local m,s,e
m=Map("autotimeset",translate("Scheduled task/startup task settings"),translate("<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>") ..
translate("N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours."))
s = m:section(TypedSection, 'global')
s.anonymous=true
e=s:option(TextValue, "customscript" ,translate("Edit Custom Script"))
e.description = translate("The execution content of the [Scheduled Customscript] in the task name")
e.rows = 5
e.default=" "
e=s:option(TextValue, "customscript2" ,translate("Edit Custom Script2"))
e.description = translate("The execution content of the [Scheduled Customscript2] in the task name")
e.rows = 5
e.default=" "
s=m:section(TypedSection,"stime","")
s.addremove=true
s.anonymous=true
s.template = "cbi/tblsection"
e=s:option(ListValue,"stype",translate("Scheduled Type"))
e:value(1,translate("Scheduled Reboot"))
e:value(2,translate("Scheduled Poweroff"))
e:value(3,translate("Scheduled ReNetwork"))
e:value(4,translate("Scheduled RestartSamba"))
e:value(16,translate("Scheduled Restartlan"))
e:value(5,translate("Scheduled Restartwan"))
e:value(6,translate("Scheduled Closewan"))
e:value(7,translate("Scheduled Clearmem"))
e:value(8,translate("Scheduled Sysfree"))
e:value(9,translate("Scheduled DisReconn"))
e:value(10,translate("Scheduled DisRereboot"))
e:value(11,translate("Scheduled Restartmwan3"))
e:value(13,translate("Scheduled Wifiup"))
e:value(14,translate("Scheduled Wifidown"))
e:value(12,translate("Scheduled Customscript"))
e:value(15,translate("Scheduled Customscript2"))
e.default=2
e=s:option(Flag,"enable",translate("Enable"))
e.rmempty = false
e.default=0
e=s:option(ListValue,"ttype",translate("Task Type"))
e:value(0,translate("Scheduled task execution"))
e:value(1,translate("Startup task"))
e.default=0
e=s:option(Value,"delay",translate("Startup delay time"))
e.default=10
e=s:option(Value,"month",translate("Month(0~11)"))
e.rmempty = false
e.default = '*'
week=s:option(Value,"week",translate("Week Day(0~6)"))
week.rmempty = true
week:value('*',translate("Everyday"))
week:value(0,translate("Sunday"))
week:value(1,translate("Monday"))
week:value(2,translate("Tuesday"))
week:value(3,translate("Wednesday"))
week:value(4,translate("Thursday"))
week:value(5,translate("Friday"))
week:value(6,translate("Saturday"))
week.default='*'
e=s:option(Value,"hour",translate("Hour(0~23)"))
e.rmempty = false
e.default = 0
e=s:option(Value,"minute",translate("Minute(0~59)"))
e.rmempty = false
e.default = 0
m.apply_on_parse = true
m.on_after_apply = function(self,map)
luci.sys.exec("/etc/init.d/autotimeset start")
end
return m

View File

@ -1,13 +0,0 @@
local fs = require "nixio.fs"
local uci = require"luci.model.uci".cursor()
local f, t
f = SimpleForm("logview")
f.reset = false
f.submit = false
t=f:field(TextValue,"conf")
t.rmempty=true
t.rows=20
t.template="autotimeset/log"
t.readonly="readonly"
return f

View File

@ -1,79 +0,0 @@
local m,s,e
m=Map("autotimeset",translate("Scheduled task"),translate("<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>") ..
translate("N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours."))
s = m:section(TypedSection, 'global')
s.anonymous=true
e=s:option(TextValue, "customscript" ,translate("Edit Custom Script"))
e.description = translate("The execution content of the [Scheduled Customscript] in the task name")
e.rows = 5
e.default=" "
e=s:option(TextValue, "customscript2" ,translate("Edit Custom Script2"))
e.description = translate("The execution content of the [Scheduled Customscript2] in the task name")
e.rows = 5
e.default=" "
s=m:section(TypedSection,"stime","")
s.addremove=true
s.anonymous=true
s.template = "cbi/tblsection"
e = s:option(Value, 'remarks', translate('Remarks'))
e=s:option(Flag,"enable",translate("Enable"))
e.rmempty = false
e.default=0
e=s:option(ListValue,"stype",translate("Scheduled Type"))
e:value(1,translate("Scheduled Reboot"))
e:value(2,translate("Scheduled Poweroff"))
e:value(3,translate("Scheduled ReNetwork"))
e:value(4,translate("Scheduled RestartSamba"))
e:value(5,translate("Scheduled Restartwan"))
e:value(6,translate("Scheduled Closewan"))
e:value(7,translate("Scheduled Clearmem"))
e:value(8,translate("Scheduled Sysfree"))
e:value(9,translate("Scheduled DisReconn"))
e:value(10,translate("Scheduled DisRereboot"))
e:value(11,translate("Scheduled Restartmwan3"))
e:value(13,translate("Scheduled Wifiup"))
e:value(14,translate("Scheduled Wifidown"))
e:value(12,translate("Scheduled Customscript"))
e:value(15,translate("Scheduled Customscript2"))
e.default=2
e=s:option(Value,"month",translate("Month(0~11)"))
e.rmempty = false
e.default = '*'
week=s:option(Value,"week",translate("Week Day(0~6)"))
week.rmempty = true
week:value('*',translate("Everyday"))
week:value(0,translate("Sunday"))
week:value(1,translate("Monday"))
week:value(2,translate("Tuesday"))
week:value(3,translate("Wednesday"))
week:value(4,translate("Thursday"))
week:value(5,translate("Friday"))
week:value(6,translate("Saturday"))
week.default='*'
e=s:option(Value,"hour",translate("Hour(0~23)"))
e.rmempty = false
e.default = 0
e=s:option(Value,"minute",translate("Minute(0~59)"))
e.rmempty = false
e.default = 0
m.apply_on_parse = true
m.on_after_apply = function(self,map)
luci.sys.exec("/etc/init.d/autotimeset start")
end
return m

View File

@ -1,57 +0,0 @@
local m,s,e
m=Map("autotimeset",translate("Startup task"),translate("<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>") ..
translate("The task to be executed upon startup, with a startup delay time unit of seconds."))
s = m:section(TypedSection, 'global')
s.anonymous=true
e=s:option(TextValue, "customscript" ,translate("Edit Custom Script"))
e.description = translate("The execution content of the [Scheduled Customscript] in the task name")
e.rows = 5
e.default=" "
e=s:option(TextValue, "customscript2" ,translate("Edit Custom Script2"))
e.description = translate("The execution content of the [Scheduled Customscript2] in the task name")
e.rows = 5
e.default=" "
s=m:section(TypedSection,"ltime","")
s.addremove=true
s.anonymous=true
s.template = "cbi/tblsection"
e = s:option(Value, 'remarks', translate('Remarks'))
e=s:option(Flag,"enable",translate("Enable"))
e.rmempty = false
e.default=0
e=s:option(ListValue,"stype",translate("Scheduled Type"))
e:value(1,translate("Scheduled Reboot"))
e:value(2,translate("Scheduled Poweroff"))
e:value(3,translate("Scheduled ReNetwork"))
e:value(4,translate("Scheduled RestartSamba"))
e:value(5,translate("Scheduled Restartwan"))
e:value(6,translate("Scheduled Closewan"))
e:value(7,translate("Scheduled Clearmem"))
e:value(8,translate("Scheduled Sysfree"))
e:value(9,translate("Scheduled DisReconn"))
e:value(10,translate("Scheduled DisRereboot"))
e:value(11,translate("Scheduled Restartmwan3"))
e:value(13,translate("Scheduled Wifiup"))
e:value(14,translate("Scheduled Wifidown"))
e:value(12,translate("Scheduled Customscript"))
e:value(15,translate("Scheduled Customscript2"))
e.default=2
e=s:option(Value,"delay",translate("Delayed Start(seconds)"))
e.default=10
m.apply_on_parse = true
m.on_after_apply = function(self,map)
luci.sys.exec("/etc/init.d/autotimeset start")
end
return m

View File

@ -1,54 +0,0 @@
<%+cbi/valueheader%>
<input type="button" class="btn cbi-button cbi-button-apply" id="apply_update_button" value="<%:Clear Log%>" onclick="apply_del_log()"/>
<input type="checkbox" name="NAME" value="reverse" onclick="reverselog()" style="vertical-align:middle;height:auto;"><%:Reverse%></input>
<textarea id="cbid.logview.1.conf" class="cbi-input-textarea" style="width: 100%;display:inline" data-update="change" rows="32" cols="60" readonly="readonly" > </textarea>
<script type="text/javascript">//<![CDATA[
var islogreverse=false;
function createAndDownloadFile(fileName,content){
var aTag=document.createElement('a');
var blob=new Blob([content]);
aTag.download=fileName;
aTag.href=URL.createObjectURL(blob);
aTag.click();
URL.revokeObjectURL(blob);
}
function apply_del_log(){
XHR.get('<%=url([[admin]],[[control]],[[autotimeset]],[[dellog]])%>',null,function(x,data){
var lv=document.getElementById('cbid.logview.1.conf');
lv.innerHTML="";
}
);
return
}
function reverselog(){
var lv=document.getElementById('cbid.logview.1.conf');
lv.innerHTML=lv.innerHTML.split('\n').reverse().join('\n')
if (islogreverse){
islogreverse=false;
}else{
islogreverse=true;
}
return
}
XHR.poll(3,'<%=url([[admin]],[[control]],[[autotimeset]],[[getlog]])%>',null,
function(x,data){
var lv=document.getElementById('cbid.logview.1.conf');
lv.innerHTML=""
if (x.responseText && lv){
if (islogreverse){
lv.innerHTML=x.responseText.split('\n').reverse().join('\n')+lv.innerHTML;
}else{
lv.innerHTML+=x.responseText;
}
}
}
)
//]]>
</script>
<%+cbi/valuefooter%>

View File

@ -1,109 +0,0 @@
msgid "<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>"
msgstr "<b>任务设置包括定时任务执行和开机启动任务执行预置重启、关机、重启网络、释放内存、系统清理、网络共享、关闭网络、自动检测断网重连、自动检测断网重启、MWAN3负载均衡检测重连、自定义脚本等10多个功能.</b></br>"
msgid "N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours."
msgstr "N1-N5连续N1,N3,N5不连续*/N表示每N小时或每N分钟。月份范围0-11星期范围06小时范围023分钟范围059不可用72小时或者90分钟等连续范围。"
msgid "Scheduled task"
msgstr "定时执行任务"
msgid "Startup task"
msgstr "开机启动任务"
msgid "The task to be executed upon startup, with a startup delay time unit of seconds."
msgstr "开机启动执行的任务,启动延时时间单位为秒。"
msgid "Control"
msgstr "管控"
msgid "Scheduled Setting"
msgstr "任务设置"
msgid "Test/Verify Settings"
msgstr "测试/验证设置"
msgid "Scheduled Type"
msgstr "任务类型"
msgid "Delayed Start(seconds)"
msgstr "开机任务延时(秒)"
msgid "Log"
msgstr "日志"
msgid "Scheduled Reboot"
msgstr "重启机器"
msgid "Scheduled Poweroff"
msgstr "关闭机器"
msgid "Scheduled ReNetwork"
msgstr "重启网络"
msgid "Scheduled RestartSamba"
msgstr "重启网络共享"
msgid "Scheduled Restartlan"
msgstr "重启LAN"
msgid "Scheduled Restartwan"
msgstr "重启WAN"
msgid "Scheduled Closewan"
msgstr "关闭网络"
msgid "Scheduled Clearmem"
msgstr "释放内存"
msgid "Scheduled Sysfree"
msgstr "系统清理(会重启机器)"
msgid "Scheduled DisReconn"
msgstr "检测断网重连"
msgid "Scheduled DisRereboot"
msgstr "检测断网重启"
msgid "Scheduled Restartmwan3"
msgstr "检测MWAN3失联重启服务"
msgid "Scheduled Wifidown"
msgstr "关闭无线网络"
msgid "Scheduled Wifiup"
msgstr "启用无线网络"
msgid "Edit Custom Script"
msgstr "【自定义脚本】编辑"
msgid "Edit Custom Script2"
msgstr "【自定义脚本2】编辑"
msgid "Scheduled Customscript"
msgstr "自定义脚本"
msgid "Scheduled Customscript2"
msgstr "自定义脚本2"
msgid "The execution content of the [Scheduled Customscript] in the task name"
msgstr "任务名称中【自定义脚本】执行内容"
msgid "The execution content of the [Scheduled Customscript2] in the task name"
msgstr "任务名称中【自定义脚本2】执行内容"
msgid "Month(0~11)"
msgstr "月份(0~11)"
msgid "Week Day(0~6)"
msgstr "星期(0~6)"
msgid "Everyday"
msgstr "每天"
msgid "Hour(0~23)"
msgstr "小时(0~23)"
msgid "Minute(0~59)"
msgstr "分钟(0~59)"

View File

@ -1,109 +0,0 @@
msgid "<b>The original [Timing Settings] includes scheduled task execution and startup task execution. Presets include over 10 functions, including restart, shutdown, network restart, memory release, system cleaning, network sharing, network shutdown, automatic detection of network disconnects and reconnection, MWAN3 load balancing detection of reconnection, and custom scripts</b></br>"
msgstr "<b>任务设置包括定时任务执行和开机启动任务执行预置重启、关机、重启网络、释放内存、系统清理、网络共享、关闭网络、自动检测断网重连、自动检测断网重启、MWAN3负载均衡检测重连、自定义脚本等10多个功能.</b></br>"
msgid "N1-N5 is continuous, N1, N3, N5 is discontinuous, */N represents every N hours or every N minutes.The week can only be 0~6, the hour can only be 0~23, the minute can only be 0~59, the unavailable time is 48 hours."
msgstr "N1-N5连续N1,N3,N5不连续*/N表示每N小时或每N分钟。月份范围0-11星期范围06小时范围023分钟范围059不可用72小时或者90分钟等连续范围。"
msgid "Scheduled task"
msgstr "定时执行任务"
msgid "Startup task"
msgstr "开机启动任务"
msgid "The task to be executed upon startup, with a startup delay time unit of seconds."
msgstr "开机启动执行的任务,启动延时时间单位为秒。"
msgid "Control"
msgstr "管控"
msgid "Scheduled Setting"
msgstr "任务设置"
msgid "Test/Verify Settings"
msgstr "测试/验证设置"
msgid "Scheduled Type"
msgstr "任务类型"
msgid "Delayed Start(seconds)"
msgstr "开机任务延时(秒)"
msgid "Log"
msgstr "日志"
msgid "Scheduled Reboot"
msgstr "重启机器"
msgid "Scheduled Poweroff"
msgstr "关闭机器"
msgid "Scheduled ReNetwork"
msgstr "重启网络"
msgid "Scheduled RestartSamba"
msgstr "重启网络共享"
msgid "Scheduled Restartlan"
msgstr "重启LAN"
msgid "Scheduled Restartwan"
msgstr "重启WAN"
msgid "Scheduled Closewan"
msgstr "关闭网络"
msgid "Scheduled Clearmem"
msgstr "释放内存"
msgid "Scheduled Sysfree"
msgstr "系统清理(会重启机器)"
msgid "Scheduled DisReconn"
msgstr "检测断网重连"
msgid "Scheduled DisRereboot"
msgstr "检测断网重启"
msgid "Scheduled Restartmwan3"
msgstr "检测MWAN3失联重启服务"
msgid "Scheduled Wifidown"
msgstr "关闭无线网络"
msgid "Scheduled Wifiup"
msgstr "启用无线网络"
msgid "Edit Custom Script"
msgstr "【自定义脚本】编辑"
msgid "Edit Custom Script2"
msgstr "【自定义脚本2】编辑"
msgid "Scheduled Customscript"
msgstr "自定义脚本"
msgid "Scheduled Customscript2"
msgstr "自定义脚本2"
msgid "The execution content of the [Scheduled Customscript] in the task name"
msgstr "任务名称中【自定义脚本】执行内容"
msgid "The execution content of the [Scheduled Customscript2] in the task name"
msgstr "任务名称中【自定义脚本2】执行内容"
msgid "Month(0~11)"
msgstr "月份(0~11)"
msgid "Week Day(0~6)"
msgstr "星期(0~6)"
msgid "Everyday"
msgstr "每天"
msgid "Hour(0~23)"
msgstr "小时(0~23)"
msgid "Minute(0~59)"
msgstr "分钟(0~59)"

View File

@ -1 +0,0 @@
# Sh script rules

View File

@ -1 +0,0 @@
# Sh script rules

View File

@ -1,78 +0,0 @@
config global
option enabled '0'
option customscript '# Sh script rules'
option customscript2 '# Sh script rules'
config stime
option hour '*/4'
option stype '7'
option week '*'
option minute '0'
option month '*'
option enable '0'
option ttype '0'
option delay '10'
option remarks '每月每天每过4小时执行一次'
config stime
option minute '0'
option month '*'
option enable '0'
option delay '10'
option stype '1'
option ttype '0'
option hour '1'
option remarks '每月星期日1:00执行'
option week '0'
config stime
option week '*'
option month '*'
option enable '0'
option ttype '0'
option delay '10'
option stype '10'
option minute '*/5'
option hour '*'
option remarks '每月每天每过5分钟执行'
config stime
option week '*'
option stype '2'
option month '*'
option enable '0'
option ttype '0'
option delay '10'
option remarks '每天22:30执行'
option hour '22'
option minute '30'
config stime
option minute '0'
option enable '0'
option ttype '0'
option delay '10'
option stype '6'
option remarks '7月星期一到星期五22:00执行'
option month '7'
option week '1-5'
option hour '22'
config stime
option week '*'
option month '*'
option stype '11'
option ttype '1'
option delay '20'
option enable '0'
option hour '*'
option remarks '每月每天每过4分钟执行'
option minute '*/4'
config ltime
option remarks '开机启动延时30秒执行'
option stype '11'
option delay '30'
option enable '0'

View File

@ -1,185 +0,0 @@
#!/bin/sh /etc/rc.common
#copyright by sirpdboy
START=95
STOP=10
TMP=/etc/autotimeset
LOG=$TMP/autotimeset.log
TT=/etc/init.d/autotimesetrun
CR=/etc/crontabs/root
[ ! -d $TMP ] && mkdir -p $TMP 2>/dev/null
[ -s $LOG ] && echo -e ' ' > $LOG
run_autotimeset()
{
[ `uci -q get autotimeset.@global[0].customscript | wc -l ` > 0 ] && uci -q get autotimeset.@global[0].customscript > /etc/autotimeset/timesetcustomscript
[ `uci -q get autotimeset.@global[0].customscript2 | wc -l ` > 0 ] && uci -q get autotimeset.@global[0].customscript2 > /etc/autotimeset/timesetcustomscript2
ssum=$(grep -c stime /etc/config/autotimeset)
lsum=$(grep -c ltime /etc/config/autotimeset)
for i in $(seq 0 $((ssum-1)))
do
enable=$(uci -q get autotimeset.@stime[$i].enable )
if [ "x$enable" = "x1" ]; then
month=$(uci -q get autotimeset.@stime[$i].month ) || month="*"
stype=$(uci -q get autotimeset.@stime[$i].stype )
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
1)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler reboot Scheduled_task"
echo "$cmd" >> $CR
;;
2)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler poweroff Scheduled_task"
echo "$cmd" >> $CR
;;
3)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler network Scheduled_task"
echo "$cmd" >> $CR
;;
4)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartsamba Scheduled_task"
echo "$cmd" >> $CR
;;
5)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartwan Scheduled_task"
echo "$cmd" >> $CR
;;
6)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler closewan Scheduled_task"
echo "$cmd" >> $CR
;;
7)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler clearmem Scheduled_task"
echo "$cmd" >> $CR
;;
8)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler sysfree Scheduled_task"
echo "$cmd" >> $CR
;;
9)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler disreconn Scheduled_task"
echo "$cmd" >> $CR
;;
10)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler disrereboot Scheduled_task"
echo "$cmd" >> $CR
;;
11)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartmwan3 Scheduled_task"
echo "$cmd" >> $CR
;;
12)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript Scheduled_task"
echo "$cmd" >> $CR
;;
13)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler upwifi Scheduled_task"
echo "$cmd" >> $CR
;;
14)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler downwifi Scheduled_task"
echo "$cmd" >> $CR
;;
15)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript2 Scheduled_task"
echo "$cmd" >> $CR
;;
16)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartlan Scheduled_task"
echo "$cmd" >> $CR
;;
esac
fi
done
for i in $(seq 0 $((lsum-1)))
do
enable=$(uci -q get autotimeset.@ltime[$i].enable )
if [ "x$enable" = "x1" ]; then
stype=$(uci -q get autotimeset.@ltime[$i].stype )
delay=$(uci -q get autotimeset.@ltime[$i].delay ) || delay=10
case "$stype" in
1)
echo "sleep $delay && /usr/bin/timesethandler reboot Startup_task" >>$TT
;;
2)
echo "sleep $delay && /usr/bin/timesethandler poweroff Startup_task" >>$TT
;;
3)
echo "sleep $delay && /usr/bin/timesethandler network Startup_task" >>$TT
;;
4)
echo "sleep $delay && /usr/bin/timesethandler restartsamba Startup_task" >>$TT
;;
5)
echo "sleep $delay && /usr/bin/timesethandler restartwan Startup_task" >>$TT
;;
6)
echo "sleep $delay && /usr/bin/timesethandler closewan Startup_task" >>$TT
;;
7)
echo "sleep $delay && /usr/bin/timesethandler clearmem Startup_task" >>$TT
;;
8)
echo "sleep $delay && /usr/bin/timesethandler reboot Startup_task" >>$TT
;;
9)
echo "sleep $delay && /usr/bin/timesethandler disreconn Startup_task" >>$TT
;;
10)
echo "sleep $delay && /usr/bin/timesethandler disrereboot Startup_task" >>$TT
;;
11)
echo "sleep $delay && /usr/bin/timesethandler restartmwan3 Startup_task" >>$TT
;;
12)
echo "sleep $delay && /usr/bin/timesethandler customscript Startup_task" >>$TT
;;
13)
echo "sleep $delay && /usr/bin/timesethandler upwifi Startup_task" >>$TT
;;
14)
echo "sleep $delay && /usr/bin/timesethandler downwifi Startup_task" >>$TT
;;
15)
echo "sleep $delay && /usr/bin/timesethandler customscript2 Startup_task" >>$TT
;;
16)
echo "sleep $delay && /usr/bin/timesethandler restartlan Startup_task" >>$TT
;;
esac
fi
done
}
start()
{
del_cru
[ -n "`tail -c1 $CR`" ] && echo >> $CR
run_autotimeset
echo '}' >>$TT
/etc/init.d/cron reload
}
stop()
{
del_cru
echo '}' >>$TT
/etc/init.d/cron reload
}
restart()
{
start
}
del_cru()
{
echo -e '#!/bin/sh /etc/rc.common\n\nSTART=99\nstart(){\necho "Service autotimesetrun started! " >> $LOG\n' > $TT
sed -i '/timesethandler/d' $CR >/dev/null 2>&1
}

View File

@ -1,5 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
start(){
echo "Service autotimesetrun started!" >/dev/null
}

View File

@ -1,14 +0,0 @@
#!/bin/sh
chmod +x /etc/init.d/autotimeset /usr/bin/timesethandler /etc/init.d/autotimesetrun
uci -q batch <<-EOF >/dev/null
delete ucitrack.@autotimeset[-1]
add ucitrack autotimeset
set ucitrack.@autotimeset[-1].init="autotimeset"
commit ucitrack
delete ucitrack.@autotimesetrun[-1]
add ucitrack autotimesetrun
set ucitrack.@autotimesetrun[-1].init=autotimesetrun
commit ucitrack
EOF
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*
exit 0

View File

@ -1,150 +0,0 @@
#!/bin/sh
# author 2021 jjm2473
# author 2020-2024 sirpdboy
TMP_T=/var/autotimeset/autotimeset.tmp
LOG=/etc/autotimeset/autotimeset.log
log(){
echo "$(date +'%Y-%m-%d %H:%M:%S') $*" >> $LOG
}
limit_log() {
local logf=$1
[ ! -f "$logf" ] && return
local sc=100
[ -n "$2" ] && sc=$2
local count=$(grep -c "" $logf)
if [ $count -gt $sc ];then
let count=count-$sc
sed -i "1,$count d" $logf
fi
}
remwan3() {
while true; do
status=$(/usr/sbin/mwan3 status | grep error)
if [ -z $status ]; then
log "Mwan3 is OK"
exit 1
else
log "mwan3 restarting ..."
/usr/sbin/mwan3 restart
fi
sleep 60
done
}
disreconnwan() {
i=0
PingA=114.114.114.114
PingB=223.5.5.5
while [[ $i -lt 5 ]]
do
if /bin/ping -c 1 $PingA >/dev/null
then
PingErr=0
break
else
if /bin/ping -c 1 $PingB >/dev/null
then
PingErr=0
break
else
i=$(($i + 1))
PingErr=1
sleep 10
fi
fi
done
}
trigger() {
case "$1" in
reboot)
reboot
;;
poweroff)
poweroff
;;
network)
/etc/init.d/network restart
;;
clearmem)
sync && echo 3 > /proc/sys/vm/drop_caches
;;
sysfree)
cd /overlay
rm -rf `ls | egrep -v '(upper|.fs_state)'`
cd upper
rm -rf `ls | egrep -v '(etc)'`
cd etc
rm -rf `ls | egrep -v '(config|ssr|bench.log|shadow)'`
rm -rf /var/luci-modulecache
rm -rf /var/luci-indexcache
rm -rf /tmp/cache/*
reboot
;;
restartsamba)
/etc/init.d/ksmdb restart
/etc/init.d/samba restart
/etc/init.d/samba4 restart
;;
restartlan)
ifdown lan && ifup lan
log "restart lan succeeded!"
;;
restartwan)
ifup wan
log "restart wan succeeded!"
;;
closewan)
ifdown wan
;;
disreconn)
disreconnwan
if [ $PingErr = 1 ]; then
ifup wan
log "Redial succeeded!"
fi
;;
disrereboot)
disreconnwan
if [ $PingErr = 1 ]; then
log "Reboot succeeded!"
reboot
fi
;;
restartmwan3)
[ -s /usr/sbin/mwan3 ] && remwan3
;;
customscript)
script=`cat /etc/autotimeset/timesetcustomscript | wc -l`
[[ $script > 0 ]] && source /etc/autotimeset/timesetcustomscript
log "CustomScript succeeded!"
;;
customscript2)
script=`cat /etc/autotimeset/timesetcustomscript2 | wc -l`
[[ $script > 0 ]] && source /etc/autotimeset/timesetcustomscript2
log "CustomScript succeeded!"
;;
upwifi)
ifconfig wlan0 up
uci set wireless.radio0.disabled=0
uci set wireless.radio1.disabled=0
uci commit wireless
wifi up
;;
downwifi)
ifconfig wlan0 down
uci set wireless.radio0.disabled=1
uci set wireless.radio1.disabled=1
uci commit wireless
wifi down
;;
esac
}
limit_log $LOG 500
PingErr=0
log "Scheduled operation $2: $1" && trigger $1

View File

@ -1,11 +0,0 @@
{
"luci-app-autotimeset": {
"description": "Grant UCI access for luci-app-autotimeset",
"read": {
"uci": [ "autotimeset" ]
},
"write": {
"uci": [ "autotimeset" ]
}
}
}