mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-06-14 20:02:04 +08:00
re-add LuCI support for Scheduled Reboot and update some translation typo
This commit is contained in:
parent
0cf8475a54
commit
cddba18888
17
package/lean/luci-app-autoreboot/Makefile
Normal file
17
package/lean/luci-app-autoreboot/Makefile
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# Copyright (C) 2016 Openwrt.org
|
||||||
|
#
|
||||||
|
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||||
|
#
|
||||||
|
|
||||||
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
|
LUCI_TITLE:=LuCI support for Scheduled Reboot
|
||||||
|
LUCI_DEPENDS:=+luci
|
||||||
|
LUCI_PKGARCH:=all
|
||||||
|
PKG_VERSION:=1.0
|
||||||
|
PKG_RELEASE:=8
|
||||||
|
|
||||||
|
include $(TOPDIR)/feeds/luci/luci.mk
|
||||||
|
|
||||||
|
# call BuildPackage - OpenWrt buildroot signature
|
||||||
|
|
@ -0,0 +1,4 @@
|
|||||||
|
module("luci.controller.autoreboot",package.seeall)
|
||||||
|
function index()
|
||||||
|
entry({"admin","system","autoreboot"},cbi("autoreboot"),_("Scheduled Reboot"),88)
|
||||||
|
end
|
@ -0,0 +1,38 @@
|
|||||||
|
require("luci.sys")
|
||||||
|
|
||||||
|
m=Map("autoreboot",translate("Scheduled Reboot"),translate("Scheduled reboot Setting"))
|
||||||
|
|
||||||
|
s=m:section(TypedSection,"login","")
|
||||||
|
s.addremove=false
|
||||||
|
s.anonymous=true
|
||||||
|
|
||||||
|
enable=s:option(Flag,"enable",translate("Enable"))
|
||||||
|
enable.rmempty = false
|
||||||
|
enable.default=0
|
||||||
|
|
||||||
|
week=s:option(ListValue,"week",translate("Week Day"))
|
||||||
|
week:value(0,translate("Everyday"))
|
||||||
|
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:value(7,translate("Sunday"))
|
||||||
|
week.default=0
|
||||||
|
|
||||||
|
hour=s:option(Value,"hour",translate("Hour"))
|
||||||
|
hour.datatype = "range(0,23)"
|
||||||
|
hour.rmempty = false
|
||||||
|
|
||||||
|
pass=s:option(Value,"minute",translate("Minute"))
|
||||||
|
pass.datatype = "range(0,59)"
|
||||||
|
pass.rmempty = false
|
||||||
|
|
||||||
|
|
||||||
|
local e=luci.http.formvalue("cbi.apply")
|
||||||
|
if e then
|
||||||
|
io.popen("/etc/init.d/autoreboot restart")
|
||||||
|
end
|
||||||
|
|
||||||
|
return m
|
25
package/lean/luci-app-autoreboot/po/zh-cn/autoreboot.po
Normal file
25
package/lean/luci-app-autoreboot/po/zh-cn/autoreboot.po
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
msgid "Scheduled Reboot"
|
||||||
|
msgstr "定时重启"
|
||||||
|
|
||||||
|
msgid "Scheduled reboot Setting"
|
||||||
|
msgstr "定时重启设置"
|
||||||
|
|
||||||
|
msgid "Week Day"
|
||||||
|
msgstr "星期"
|
||||||
|
|
||||||
|
msgid "Everyday"
|
||||||
|
msgstr "每天"
|
||||||
|
|
||||||
|
msgid "Day"
|
||||||
|
msgstr "天"
|
||||||
|
|
||||||
|
msgid "Hour"
|
||||||
|
msgstr "小时"
|
||||||
|
|
||||||
|
msgid "Minute"
|
||||||
|
msgstr "分钟"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
config login
|
||||||
|
option minute '0'
|
||||||
|
option hour '5'
|
||||||
|
option week '3'
|
||||||
|
option enable '0'
|
||||||
|
|
39
package/lean/luci-app-autoreboot/root/etc/init.d/autoreboot
Executable file
39
package/lean/luci-app-autoreboot/root/etc/init.d/autoreboot
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh /etc/rc.common
|
||||||
|
START=50
|
||||||
|
|
||||||
|
run_reboot()
|
||||||
|
{
|
||||||
|
local enable
|
||||||
|
config_get_bool enable $1 enable
|
||||||
|
|
||||||
|
if [ $enable = 1 ]; then
|
||||||
|
local minute
|
||||||
|
local hour
|
||||||
|
config_get week $1 week
|
||||||
|
config_get minute $1 minute
|
||||||
|
config_get hour $1 hour
|
||||||
|
if [ $minute = 0 ] ; then
|
||||||
|
minute="00"
|
||||||
|
fi
|
||||||
|
if [ $week = 0 ] ; then
|
||||||
|
week="*"
|
||||||
|
fi
|
||||||
|
sed -i '/reboot/d' /etc/crontabs/root >/dev/null 2>&1
|
||||||
|
echo "$minute $hour * * $week sleep 5 && touch /etc/banner && reboot" >> /etc/crontabs/root
|
||||||
|
echo "Auto REBOOT has started."
|
||||||
|
else
|
||||||
|
sed -i '/reboot/d' /etc/crontabs/root >/dev/null 2>&1
|
||||||
|
echo "Auto REBOOT has started."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
start()
|
||||||
|
{
|
||||||
|
config_load autoreboot
|
||||||
|
config_foreach run_reboot login
|
||||||
|
}
|
||||||
|
|
||||||
|
stop()
|
||||||
|
{
|
||||||
|
echo "Auto REBOOT has stoped."
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user