update 2025-01-04 04:20:30

This commit is contained in:
kenzok8 2025-01-04 04:20:30 +08:00
parent 617bd1a911
commit 4f2074917c
27 changed files with 376 additions and 110 deletions

View File

@ -11,8 +11,8 @@ PKG_NAME:=luci-app-$(NAME)
LUCI_TITLE:=LuCI support for Scheduled Time setting
LUCI_PKGARCH:=all
PKG_VERSION:=2.1.0
PKG_RELEASE:=20240318
PKG_VERSION:=2.2.0
PKG_RELEASE:=20240412
define Package/$(PKG_NAME)/conffiles

View File

@ -6,16 +6,16 @@ function index()
return
end
entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false
local e = entry({"admin", "control", "autotimeset"}, alias("admin", "control", "autotimeset", "base"), _("Scheduled Setting"), 20)
local e = entry({"admin", "control", "autotimeset"}, alias("admin", "control", "autotimeset", "scheduledtask"), _("Scheduled Setting"), 20)
e.dependent = false
e.acl_depends = { "luci-app-autotimeset" }
entry({"admin", "control", "autotimeset", "base"}, cbi("autotimeset/base"), _("Scheduled Setting"), 1).leaf = true
entry({"admin", "control", "autotimeset", "log"}, form("autotimeset/log"), _("Log"), 2).leaf = true
entry({"admin", "control", "autotimeset", "scheduledtask"}, cbi("autotimeset/scheduledtask"), _("Scheduled task"), 10).leaf = true
entry({"admin", "control", "autotimeset", "startuptask"}, cbi("autotimeset/startuptask"), _("Startup task"), 20).leaf = true
entry({"admin", "control", "autotimeset", "log"}, form("autotimeset/log"), _("Log"), 30).leaf = true
entry({"admin","control","autotimeset","dellog"},call("dellog"))
entry({"admin","control","autotimeset","getlog"},call("getlog"))
end
function getlog()
logfile="/etc/autotimeset/autotimeset.log"
if not fs.access(logfile) then

View File

@ -30,6 +30,7 @@ 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"))
@ -37,9 +38,9 @@ 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(12,translate("Scheduled Customscript"))
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

View File

@ -0,0 +1,79 @@
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

@ -0,0 +1,57 @@
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

@ -5,8 +5,17 @@ msgstr "<b>任务设置包括定时任务执行和开机启动任务执行,预
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/startup task settings"
msgstr "定时执行任务/开机启动任务设置"
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 "任务设置"
@ -15,19 +24,10 @@ msgid "Test/Verify Settings"
msgstr "测试/验证设置"
msgid "Scheduled Type"
msgstr "任务名称"
msgid "Task Type"
msgstr "任务类型"
msgid "Scheduled task execution"
msgstr "定时执行任务"
msgid "Startup task"
msgstr "开机启动任务"
msgid "Startup delay time"
msgstr "延迟时间【开机用】"
msgid "Delayed Start(seconds)"
msgstr "开机任务延时(秒)"
msgid "Log"
msgstr "日志"
@ -44,6 +44,9 @@ msgstr "重启网络"
msgid "Scheduled RestartSamba"
msgstr "重启网络共享"
msgid "Scheduled Restartlan"
msgstr "重启LAN"
msgid "Scheduled Restartwan"
msgstr "重启WAN"
@ -90,17 +93,17 @@ msgid "The execution content of the [Scheduled Customscript2] in the task name"
msgstr "任务名称中【自定义脚本2】执行内容"
msgid "Month(0~11)"
msgstr "月份(0~11)【定时用】"
msgstr "月份(0~11)"
msgid "Week Day(0~6)"
msgstr "星期(0~6)【定时用】"
msgstr "星期(0~6)"
msgid "Everyday"
msgstr "每天【定时用】"
msgstr "每天"
msgid "Hour(0~23)"
msgstr "小时(0~23)【定时用】"
msgstr "小时(0~23)"
msgid "Minute(0~59)"
msgstr "分钟(0~59)【定时用】"
msgstr "分钟(0~59)"

View File

@ -5,8 +5,17 @@ msgstr "<b>任务设置包括定时任务执行和开机启动任务执行,预
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/startup task settings"
msgstr "定时执行任务/开机启动任务设置"
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 "任务设置"
@ -15,19 +24,10 @@ msgid "Test/Verify Settings"
msgstr "测试/验证设置"
msgid "Scheduled Type"
msgstr "任务名称"
msgid "Task Type"
msgstr "任务类型"
msgid "Scheduled task execution"
msgstr "定时执行任务"
msgid "Startup task"
msgstr "开机启动任务"
msgid "Startup delay time"
msgstr "延迟时间【开机用】"
msgid "Delayed Start(seconds)"
msgstr "开机任务延时(秒)"
msgid "Log"
msgstr "日志"
@ -44,6 +44,9 @@ msgstr "重启网络"
msgid "Scheduled RestartSamba"
msgstr "重启网络共享"
msgid "Scheduled Restartlan"
msgstr "重启LAN"
msgid "Scheduled Restartwan"
msgstr "重启WAN"
@ -90,17 +93,17 @@ msgid "The execution content of the [Scheduled Customscript2] in the task name"
msgstr "任务名称中【自定义脚本2】执行内容"
msgid "Month(0~11)"
msgstr "月份(0~11)【定时用】"
msgstr "月份(0~11)"
msgid "Week Day(0~6)"
msgstr "星期(0~6)【定时用】"
msgstr "星期(0~6)"
msgid "Everyday"
msgstr "每天【定时用】"
msgstr "每天"
msgid "Hour(0~23)"
msgstr "小时(0~23)【定时用】"
msgstr "小时(0~23)"
msgid "Minute(0~59)"
msgstr "分钟(0~59)【定时用】"
msgstr "分钟(0~59)"

View File

@ -1,3 +1,4 @@
config global
option enabled '0'
option customscript '# Sh script rules'
@ -12,16 +13,18 @@ config stime
option enable '0'
option ttype '0'
option delay '10'
option remarks '每月每天每过4小时执行一次'
config stime
option minute '0'
option month '*'
option enable '0'
option week '1,3,5'
option delay '10'
option stype '1'
option ttype '0'
option hour '1'
option remarks '每月星期日1:00执行'
option week '0'
config stime
option week '*'
@ -32,44 +35,44 @@ config stime
option stype '10'
option minute '*/5'
option hour '*'
option remarks '每月每天每过5分钟执行'
config stime
option week '*'
option minute '0'
option stype '2'
option hour '1'
option month '*'
option enable '0'
option ttype '0'
option delay '10'
option remarks '每天22:30执行'
option hour '22'
option minute '30'
config stime
option week '*'
option minute '0'
option hour '3'
option month '*'
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 minute '*/5'
option month '*'
option stype '11'
option ttype '1'
option delay '20'
option enable '0'
option hour '*'
option remarks '每月每天每过4分钟执行'
option minute '*/4'
config stime
option month '*'
option week '*'
option enable '0'
option minute '*/5'
option stype '12'
option ttype '1'
config ltime
option remarks '开机启动延时30秒执行'
option stype '11'
option delay '30'
option hour '*'
option enable '0'

View File

@ -8,12 +8,13 @@ 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
[ -s $LOG ] && echo -e ' ' > $LOG
run_autotimeset()
{
ssum=$(grep -c stime /etc/config/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 )
@ -23,74 +24,136 @@ 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="*"
ttype=$(uci -q get autotimeset.@stime[$i].ttype ) || ttype=0
delay=$(uci -q get autotimeset.@stime[$i].delay ) || delay=10
[ "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"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler reboot Startup_task" >>$TT
echo "$cmd" >> $CR
;;
2)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler poweroff Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler poweroff Startup_task" >>$TT
echo "$cmd" >> $CR
;;
3)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler network Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler network Startup_task" >>$TT
echo "$cmd" >> $CR
;;
4)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartsamba Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler restartsamba Startup_task" >>$TT
echo "$cmd" >> $CR
;;
5)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartwan Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler restartwan Startup_task" >>$TT
echo "$cmd" >> $CR
;;
6)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler closewan Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler closewan Startup_task" >>$TT
echo "$cmd" >> $CR
;;
7)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler clearmem Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler clearmem Startup_task" >>$TT
echo "$cmd" >> $CR
;;
8)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler sysfree Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler reboot Startup_task" >>$TT
echo "$cmd" >> $CR
;;
9)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler disreconn Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler disreconn Startup_task" >>$TT
echo "$cmd" >> $CR
;;
10)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler disrereboot Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler disrereboot Startup_task" >>$TT
echo "$cmd" >> $CR
;;
11)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler restartmwan3 Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler restartmwan3 Startup_task" >>$TT
echo "$cmd" >> $CR
;;
12)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript Startup_task" >>$TT
echo "$cmd" >> $CR
;;
13)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler upwifi Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler upwifi Startup_task" >>$TT
echo "$cmd" >> $CR
;;
14)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler downwifi Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler downwifi Startup_task" >>$TT
echo "$cmd" >> $CR
;;
15)
local cmd="$minute $hour * $month $week /usr/bin/timesethandler customscript2 Scheduled_task"
[ $ttype = '0' ] && echo "$cmd" >> $CR || echo "sleep $delay && /usr/bin/timesethandler customscript2 Startup_task" >>$TT
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()
@ -116,7 +179,7 @@ restart()
del_cru()
{
echo -e '#!/bin/sh /etc/rc.common\n\nSTART=99\nstart(){\necho "Service autotimesetrun started! " >> $LOG\n' > $TT
echo -e '#!/bin/sh \n\nSTART=99\nstart(){\necho "Service autotimesetrun started! " >> $LOG\n' > $TT
sed -i '/timesethandler/d' $CR >/dev/null 2>&1
}

View File

@ -31,7 +31,6 @@ while true; do
fi
sleep 60
done
}
disreconnwan() {
@ -89,9 +88,14 @@ trigger() {
/etc/init.d/samba restart
/etc/init.d/samba4 restart
;;
restartlan)
ifdown lan && ifup lan
log "restart lan succeeded!"
;;
restartwan)
ifup wan
log "Redial succeeded!"
log "restart wan succeeded!"
;;
closewan)
ifdown wan

View File

@ -8,8 +8,8 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-netspeedtest
PKG_VERSION:=2.2.4
PKG_RELEASE:=20240319
PKG_VERSION:=2.3.0
PKG_RELEASE:=20250104
LUCI_TITLE:=LuCI Support for netspeedtest
LUCI_DEPENDS:=+python3 +iperf3-ssl +homebox

View File

@ -1,4 +1,4 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
-- Copyright (C) 2020-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
module("luci.controller.netspeedtest", package.seeall)
local http = require "luci.http"
@ -16,7 +16,8 @@ function index()
entry({"admin", "network", "netspeedtest", "speedtestlan"},cbi("netspeedtest/speedtestlan"),_("Lan Speedtest Web"),20).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestiperf3"},cbi("netspeedtest/speedtestiperf3", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Lan Speedtest Iperf3"),30).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestwan"},cbi("netspeedtest/speedtestwan", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Broadband speed test"), 40).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestwan"},cbi("netspeedtest/speedtestwan", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Broadband speedtest"), 40).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestwanweb"},cbi("netspeedtest/speedtestwanweb", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Broadband OpenSpeedtest"), 41).leaf = true
entry({"admin", "network", "netspeedtest", "speedtestport"},cbi("netspeedtest/speedtestport", {hideapplybtn=true, hidesavebtn=true, hideresetbtn=true}),_("Server Port Latency Test"), 50).leaf = true
entry({"admin", "network", "netspeedtest", "log"}, form("netspeedtest/log"), _("Log"), 60).leaf = true
entry({"admin", "network", "netspeedtest", "test_port"}, call("test_port"))
@ -31,12 +32,12 @@ end
function netcheck()
http.prepare_content("text/plain; charset=utf-8")
local f=io.open("/etc/netspeedtest/netspeedtest.log", "r+")
local fdp=fs.readfile("/etc/netspeedtest/netspeedtestpos") or 0
local f=io.open("/tmp/netspeedtest.log", "r+")
local fdp=fs.readfile("/tmp/netspeedtestpos") or 0
f:seek("set",fdp)
local a=f:read(2048000) or ""
fdp=f:seek()
fs.writefile("/etc/netspeedtest/netspeedtestpos",tostring(fdp))
fs.writefile("/tmp/netspeedtestpos",tostring(fdp))
f:close()
http.write(a)
end
@ -45,10 +46,10 @@ function speedtestwanrun()
local cli = luci.http.formvalue('cli')
uci:set(name, 'speedtestwan', 'speedtest_cli', cli)
uci:commit(name)
fs.writefile("/etc/netspeedtest/netspeedtestpos","0")
fs.writefile("/tmp/netspeedtestpos","0")
http.prepare_content("application/json")
http.write('')
sys.exec(string.format("/etc/init.d/netspeedtest wantest " ..cli.. " > /etc/netspeedtest/netspeedtest.log 2>&1 &" ))
sys.exec(string.format("/etc/init.d/netspeedtest wantest " ..cli.. " > /tmp/netspeedtest.log 2>&1 &" ))
end
function test_port()

View File

@ -1,4 +1,4 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
-- Copyright (C) 2020-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
require("luci.util")
local o,s,e

View File

@ -1,4 +1,4 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
-- Copyright (C) 2020-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
local m, s ,o
m = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )

View File

@ -1,4 +1,4 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
-- Copyright (C) 2020-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
require("luci.util")
local o,t,e

View File

@ -1,10 +1,12 @@
-- Copyright (C) 2020-2022 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
-- Copyright (C) 2020-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
require("luci.util")
local o,t,e
luci.sys.exec("echo '-' >/tmp/netspeedtest.log&&echo 1 > /tmp/netspeedtestpos" )
o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
t=o:section(TypedSection,"speedtestwan",translate("Broadband speed test"))
t=o:section(TypedSection,"speedtestwan",translate("Broadband speedtest"))
t.anonymous=true
e = t:option(ListValue, 'speedtest_cli', translate('client version selection'))

View File

@ -0,0 +1,15 @@
-- Copyright (C) 2020-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
require("luci.util")
local o,t,e
luci.sys.exec("echo '-' >/tmp/netspeedtest.log&&echo 1 > /tmp/netspeedtestpos" )
o = Map("netspeedtest", "<font color='green'>" .. translate("Net Speedtest") .."</font>",translate( "Network speed diagnosis test (including intranet and extranet)<br/>For specific usage, see:") ..translate("<a href=\'https://github.com/sirpdboy/netspeedtest.git' target=\'_blank\'>GitHub @sirpdboy/netspeedtest</a>") )
t=o:section(TypedSection,"speedtestwan",translate("Broadband OpenSpeedtest"))
t.anonymous=true
e = t:option(DummyValue, '', '')
e.rawhtml = true
e.template ='netspeedtest/speedtestwanweb'
return o

View File

@ -1,5 +1,5 @@
<%#
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
Copyright 2020-2025 sirpdboy Wich <sirpdboy@qq.com>
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>

View File

@ -1,5 +1,5 @@
<%#
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
Copyright 2020-2025 sirpdboy Wich <sirpdboy@qq.com>
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>

View File

@ -1,5 +1,5 @@
<%#
Copyright 2020-2024 sirpdboy Wich <sirpdboy@qq.com>
Copyright 2020-2025 sirpdboy Wich <sirpdboy@qq.com>
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>

View File

@ -1,5 +1,5 @@
<%#
Copyright 2020-2022 sirpdboy Wich <sirpdboy@qq.com>
Copyright 2020-2025 sirpdboy Wich <sirpdboy@qq.com>
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>

View File

@ -0,0 +1,10 @@
<%#
Copyright 2020-2025 sirpdboy Wich <sirpdboy@qq.com>
https://github.com/sirpdboy/netspeedtest
Licensed to the public under the Apache License 2.0.
-%>
<%+cbi/valueheader%>
<!--OST Widget code start--><div style="text-align:right;"><div style="min-height:360px;"><div style="width:100%;height:0;padding-bottom:50%;position:relative;"><iframe style="border:none;position:absolute;top:0;left:0;width:100%;height:100%;min-height:360px;border:none;overflow:hidden !important;" src="//openspeedtest.com/speedtest"></iframe></div></div>Provided by OpenSpeedtest.com </div><!-- OST Widget code end -->
<%+cbi/valuefooter%>

View File

@ -25,6 +25,12 @@ msgstr "本地iperf3吞吐测速"
msgid "Lan Speedtest Web"
msgstr "本地测速网页版"
msgid "Broadband speedtest"
msgstr "宽带测速speedtest"
msgid "Broadband OpenSpeedtest"
msgstr "宽带测速OpenSpeedtest"
msgid "Running state"
msgstr "运行状态"
@ -94,9 +100,6 @@ msgstr "Github下载iperf3"
msgid "Iperf3 speed measurement software download"
msgstr "iperf3测速软件下载"
msgid "Broadband speed test"
msgstr "宽带网速测试"
msgid "speedtest.net Broadband speed test"
msgstr "speedtest.net宽带网速测试"

View File

@ -25,6 +25,12 @@ msgstr "本地iperf3吞吐测速"
msgid "Lan Speedtest Web"
msgstr "本地测速网页版"
msgid "Broadband speedtest"
msgstr "宽带测速speedtest"
msgid "Broadband OpenSpeedtest"
msgstr "宽带测速OpenSpeedtest"
msgid "Running state"
msgstr "运行状态"
@ -94,9 +100,6 @@ msgstr "Github下载iperf3"
msgid "Iperf3 speed measurement software download"
msgstr "iperf3测速软件下载"
msgid "Broadband speed test"
msgstr "宽带网速测试"
msgid "speedtest.net Broadband speed test"
msgstr "speedtest.net宽带网速测试"

View File

@ -1,7 +1,7 @@
#!/bin/sh /etc/rc.common
#
# Copyright (C) 2020-2023 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
# Copyright (C) 2020-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/netspeedtest
# This is free software, licensed under the Apache License, Version 2.0 .
#
@ -20,7 +20,7 @@ LOG=/var/log/netspeedtest.log
LOGE=$LOGD/netspeedtest.log
LOGT=$LOGD/netspeedtestpos
[ -d "$LOGD" ] || mkdir -p $LOGD
[ -f "$LOGE" ] || echo "start" > $LOG
[ -f "$LOGE" ] || echo "start" > $LOGE
[ -f "$LOGT" ] || echo "start" > $LOGT
[ -f "$LOG" ] || echo "start" > $LOG

View File

@ -1,6 +1,25 @@
#!/bin/sh
chmod +x /etc/init.d/netspeedtest >/dev/null 2>&1
[ `uci -q get partexp.global` ] && uci set partexp.global=global
[ -f "/etc/config/netspeedtest" ] || {
cat >/etc/config/netspeedtest <<-EOF
config netspeedtest 'netspeedtest'
option enabled '0'
option port '3300'
config homebox 'homebox'
option enabled '0'
option port '3300'
config speedtestiperf3 'speedtestiperf3'
config speedtestwan 'speedtestwan'
config speedtestport 'speedtestport'
option sport '443'
option sdomain 'www.taobao.com'
EOF
}
[ `uci -q get netspeedtest.global` ] && uci set netspeedtest.global=global
[ `uci -q get netspeedtest.netspeedtest` ] || uci set netspeedtest.netspeedtest=netspeedtest
[ `uci -q get netspeedtest.speedtestiperf3` ] || uci set netspeedtest.speedtestiperf3=speedtestiperf3
[ `uci -q get netspeedtest.speedtestport` ] || uci set netspeedtest.speedtestport=speedtestport
@ -10,8 +29,8 @@ LOG=/var/log/netspeedtest.log
LOGE=$LOGD/netspeedtest.log
LOGT=$LOGD/netspeedtestpos
[ -d "$LOGD" ] || mkdir -p $LOGD
[ -f "$LOGE" ] || echo "start" > $LOG
[ -f "$LOGT" ] || echo "start" > $LOGT
[ -f "$LOGE" ] || echo "start" > $LOGE
[ -f "$LOGT" ] || echo "1" > $LOGT
[ -f "$LOG" ] || echo "start" > $LOG
rm -rf /tmp/luci-modulecache /tmp/luci-indexcache*

View File

@ -5,7 +5,7 @@
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# Copyright (C) 2019-2024 The Sirpdboy Team <herboy2008@gmail.com>
# Copyright (C) 2019-2025 The Sirpdboy Team <herboy2008@gmail.com>
# . /lib/netspeedtest/functions.sh
################################################################################