From 28b61e83f8ad178a7116439072b167d2c2a2d23d Mon Sep 17 00:00:00 2001 From: SirPdboy <63764630+sirpdboy@users.noreply.github.com> Date: Mon, 2 Nov 2020 16:59:14 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=9A=E6=97=B6=E9=87=8D=E5=90=AF?= =?UTF-8?q?=E5=85=B3=E6=9C=BA1.3=20=E4=BA=8C=E5=90=88=E4=B8=80=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index abb267d..21ceaf4 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,34 @@ luci-app-autopoweroff for OpenWRT/Lede(中文) 源码地址 https://github.com/sirpdboy/luci-app-autopoweroff -定时重启关机二合一升级版。 + +定时重启关机1.3 二合一升级版,你可以免费使用代码,但请注明出处。 +彻底解决需要保存二次才生效的问题。 Install to OpenWRT/LEDE + git clone https://github.com/sirpdboy/luci-app-autopoweroff + cp -r luci-app-autopoweroff LEDE_DIR/package/luci-app-autopoweroff + cd LEDE_DIR + ./scripts/feeds update -a + ./scripts/feeds install -a + make menuconfig + LuCI ---> + 1. Collections ---> + <*> luci + 3. Applications ---> + <*> luci-app-autopoweroff.........................LuCI support for Scheduled poweroff - - -make package/luci-app-autopoweroff/compile V=s \ No newline at end of file + +make package/luci-app-autopoweroff/compile V=s From 03c045e16735522daa12ac5a2810ec8901ef20c8 Mon Sep 17 00:00:00 2001 From: SirPdboy <63764630+sirpdboy@users.noreply.github.com> Date: Sat, 6 Feb 2021 17:10:25 +0800 Subject: [PATCH 2/4] up readme --- LICENSE | 42 +++++++++---------- Makefile | 38 ++++++++--------- README.md | 120 ++++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 126 insertions(+), 74 deletions(-) diff --git a/LICENSE b/LICENSE index c1c854b..02a5512 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,21 @@ -MIT License - -Copyright (c) 2019-2020 johnrosen1 - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT License + +Copyright (c) 2019-2020 johnrosen1 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile index db127df..462dcb7 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,19 @@ -# Copyright (C) 2019 sirpdboy -# -# This is free software, licensed under the Apache License, Version 2.0 . -# - -include $(TOPDIR)/rules.mk - -LUCI_TITLE:=LuCI support for Scheduled setting -LUCI_DEPENDS:=+luci -LUCI_PKGARCH:=all -PKG_VERSION:=1.3 -PKG_RELEASE:=2 - -PKG_MAINTAINER:=sirpdboy - -include $(TOPDIR)/feeds/luci/luci.mk - -# call BuildPackage - OpenWrt buildroot signature - +# Copyright (C) 2019 sirpdboy +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI support for Scheduled setting +LUCI_DEPENDS:=+luci +LUCI_PKGARCH:=all +PKG_VERSION:=1.3 +PKG_RELEASE:=2 + +PKG_MAINTAINER:=sirpdboy + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + diff --git a/README.md b/README.md index 21ceaf4..9b36575 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,86 @@ -luci-app-autopoweroff for OpenWRT/Lede(中文) -源码地址 https://github.com/sirpdboy/luci-app-autopoweroff - -定时重启关机1.3 二合一升级版,你可以免费使用代码,但请注明出处。 -彻底解决需要保存二次才生效的问题。 - -Install to OpenWRT/LEDE - - -git clone https://github.com/sirpdboy/luci-app-autopoweroff - -cp -r luci-app-autopoweroff LEDE_DIR/package/luci-app-autopoweroff - - -cd LEDE_DIR - -./scripts/feeds update -a - -./scripts/feeds install -a - - -make menuconfig - -LuCI ---> - - 1. Collections ---> - - <*> luci - - 3. Applications ---> - - <*> luci-app-autopoweroff.........................LuCI support for Scheduled poweroff - -make package/luci-app-autopoweroff/compile V=s +[![若部分图片无法正常显示,请挂上机场浏览或点这里到末尾看修复教程](https://visitor-badge.glitch.me/badge?page_id=sirpdboy-visitor-badge)](#解决-github-网页上图片显示失败的问题) [![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ) + +[autopoweroff自动定时重启关机插件](https://github.com/sirpdboy/luci-app-autopoweroff) +====================== +请 **认真阅读完毕** 本页面,本页面包含注意事项和如何使用。 + +## 功能说明: + +定时设置重启和定时设置关机二合一升级版,解决原本需要保存二次才能生效的问题。 + +## 编译使用方法 [![](https://img.shields.io/badge/-编译使用方法-F5F5F5.svg)](#编译使用方法-) + +将luci-app-autopoweroff添加至 LEDE/OpenWRT 源码的方法。 + +### 下载源码方法一: +编辑源码文件夹根目录feeds.conf.default并加入如下内容: + +```Brach + # feeds获取源码: + src-git autopoweroff https://github.com/sirpdboy/luci-app-autopoweroff + ``` + ```Brach + # 更新feeds,并安装主题: + scripts/feeds update autopoweroff + scripts/feeds install luci-app-autopoweroff + ``` + +### 下载源码方法二: + ```Brach + # 下载源码 + git clone https://github.com/sirpdboy/luci-app-autopoweroff package/luci-app-autopoweroff + make menuconfig + ``` +### 配置菜单 + ```Brach + make menuconfig + # 找到 LuCI -> Themes, 选择 luci-app-autopoweroff, 保存后退出。 + ``` +### 编译 + ```Brach + # 编译固件 + make package/luci-app-autopoweroff/compile V=s + ``` + +## 说明 [![](https://img.shields.io/badge/-说明-F5F5F5.svg)](#说明-) + +源码来源:https://github.com/sirpdboy/luci-app-autopoweroff/compile + +你可以随意使用其中的源码,但请注明出处。 +============================ + +# My other project +网络速度测试 :https://github.com/sirpdboy/NetSpeedTest + +定时关机重启 : https://github.com/sirpdboy/luci-app-autopoweroff + +关机功能插件 : https://github.com/sirpdboy/luci-app-poweroffdevice + +opentopd主题 : https://github.com/sirpdboy/luci-theme-opentopd + +opentoks 主题: https://github.com/sirpdboy/luci-theme-opentoks [仿KOOLSAHRE主题] + +btmob 主题: https://github.com/sirpdboy/luci-theme-btmob + +系统高级设置 : https://github.com/sirpdboy/luci-app-advanced + +## 捐助 [![](https://img.shields.io/badge/-捐助-F5F5F5.svg)](#捐助-) + +**如果你觉得此项目对你有帮助,请捐助我们,以使项目能持续发展,更加完善。··请作者喝杯咖啡~~~** + +**你们的支持就是我的动力!** + +### 捐助方式 + +| 图飞了😂 | 图飞了😂 | +| :-----------------: | :-------------: | +|图飞了😂|图飞了😂| + + + 图飞了😂 + + +###### [解决 Github 网页上图片显示失败的问题](https://blog.csdn.net/qq_38232598/article/details/91346392) + +[![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ) + From 4f5277919e3aa46981e864a0cd3b779d04e3e2a6 Mon Sep 17 00:00:00 2001 From: SirPdboy <63764630+sirpdboy@users.noreply.github.com> Date: Sat, 6 Feb 2021 17:15:51 +0800 Subject: [PATCH 3/4] readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9b36575..337e949 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ ## 说明 [![](https://img.shields.io/badge/-说明-F5F5F5.svg)](#说明-) -源码来源:https://github.com/sirpdboy/luci-app-autopoweroff/compile +源码来源:https://github.com/sirpdboy/luci-app-autopoweroff 你可以随意使用其中的源码,但请注明出处。 ============================ @@ -74,7 +74,7 @@ btmob 主题: https://github.com/sirpdboy/luci-theme-btmob | 图飞了😂 | 图飞了😂 | | :-----------------: | :-------------: | -|图飞了😂|图飞了😂| +|图飞了😂|图飞了😂| 图飞了😂 From 97c14fcfb80e231111cd69411a47ee875c53e130 Mon Sep 17 00:00:00 2001 From: SirPdboy <63764630+sirpdboy@users.noreply.github.com> Date: Sun, 7 Feb 2021 14:17:46 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=20=201.4=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E9=87=8D=E5=90=AF=E7=BD=91=E7=BB=9C=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 升级定时设置 1.4,增加定时重启网络功能。 --- Makefile | 10 +-- README.md | 32 +++++--- luasrc/controller/autotimeset.lua | 4 + luasrc/model/cbi/autotimeset.lua | 47 ++++++++++++ po/zh-cn/autotimeset.po | 30 ++++++++ root/etc/config/autotimeset | 6 ++ root/etc/init.d/autotimeset | 117 ++++++++++++++++++++++++++++++ 7 files changed, 230 insertions(+), 16 deletions(-) create mode 100644 luasrc/controller/autotimeset.lua create mode 100644 luasrc/model/cbi/autotimeset.lua create mode 100644 po/zh-cn/autotimeset.po create mode 100644 root/etc/config/autotimeset create mode 100644 root/etc/init.d/autotimeset diff --git a/Makefile b/Makefile index 462dcb7..318ed5b 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,17 @@ -# Copyright (C) 2019 sirpdboy +# Copyright (C) 2019-2021 sirpdboy https://github.com/sirpdboy/luci-app-autotimeset # # This is free software, licensed under the Apache License, Version 2.0 . # include $(TOPDIR)/rules.mk -LUCI_TITLE:=LuCI support for Scheduled setting +LUCI_TITLE:=LuCI support for Scheduled Time setting LUCI_DEPENDS:=+luci LUCI_PKGARCH:=all -PKG_VERSION:=1.3 -PKG_RELEASE:=2 +PKG_VERSION:=1.4 +PKG_RELEASE:=3 -PKG_MAINTAINER:=sirpdboy +PKG_MAINTAINER:=sirpdboy https://github.com/sirpdboy/luci-app-autotimeset include $(TOPDIR)/feeds/luci/luci.mk diff --git a/README.md b/README.md index 337e949..ffb249f 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,60 @@ [![若部分图片无法正常显示,请挂上机场浏览或点这里到末尾看修复教程](https://visitor-badge.glitch.me/badge?page_id=sirpdboy-visitor-badge)](#解决-github-网页上图片显示失败的问题) [![](https://img.shields.io/badge/TG群-点击加入-FFFFFF.svg)](https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ) -[autopoweroff自动定时重启关机插件](https://github.com/sirpdboy/luci-app-autopoweroff) +[autotimeset 定时设置插件](https://github.com/sirpdboy/luci-app-autotimeset) ====================== 请 **认真阅读完毕** 本页面,本页面包含注意事项和如何使用。 ## 功能说明: -定时设置重启和定时设置关机二合一升级版,解决原本需要保存二次才能生效的问题。 +### 定时设置1.4版 +#### 2021.2.7 新增功能定时重启网络。现包括:定时重启、定时关机、定时重启网络,各功能可一起使用。 + +### 定时设置1.3版 +#### 2020.10.6 原来重定关机正式改名为定时设置,实现定时重启和定时关机功能二合一。 + +### 定时关机1.1版 +#### 2020.7.19 定时关机功能,彻底解决需要保存二次才生效的问题。 + +### 定时关机1.0版 +#### 2019.2.24 定时关机功能借鉴前辈们的开源代码首发。 ## 编译使用方法 [![](https://img.shields.io/badge/-编译使用方法-F5F5F5.svg)](#编译使用方法-) -将luci-app-autopoweroff添加至 LEDE/OpenWRT 源码的方法。 +将luci-app-autotimeset添加至 LEDE/OpenWRT 源码的方法。 ### 下载源码方法一: 编辑源码文件夹根目录feeds.conf.default并加入如下内容: ```Brach # feeds获取源码: - src-git autopoweroff https://github.com/sirpdboy/luci-app-autopoweroff + src-git autotimeset https://github.com/sirpdboy/luci-app-autotimeset ``` ```Brach # 更新feeds,并安装主题: - scripts/feeds update autopoweroff - scripts/feeds install luci-app-autopoweroff + scripts/feeds update autotimeset + scripts/feeds install luci-app-autotimeset ``` ### 下载源码方法二: ```Brach # 下载源码 - git clone https://github.com/sirpdboy/luci-app-autopoweroff package/luci-app-autopoweroff + git clone https://github.com/sirpdboy/luci-app-autotimeset package/luci-app-autotimeset make menuconfig ``` ### 配置菜单 ```Brach make menuconfig - # 找到 LuCI -> Themes, 选择 luci-app-autopoweroff, 保存后退出。 + # 找到 LuCI -> Applications, 选择 luci-app-autotimeset, 保存后退出。 ``` ### 编译 ```Brach # 编译固件 - make package/luci-app-autopoweroff/compile V=s + make package/luci-app-autotimeset/compile V=s ``` ## 说明 [![](https://img.shields.io/badge/-说明-F5F5F5.svg)](#说明-) -源码来源:https://github.com/sirpdboy/luci-app-autopoweroff +源码来源:https://github.com/sirpdboy/luci-app-autotimeset 你可以随意使用其中的源码,但请注明出处。 ============================ @@ -52,7 +62,7 @@ # My other project 网络速度测试 :https://github.com/sirpdboy/NetSpeedTest -定时关机重启 : https://github.com/sirpdboy/luci-app-autopoweroff +定时设置插件 : https://github.com/sirpdboy/luci-app-autotimeset 关机功能插件 : https://github.com/sirpdboy/luci-app-poweroffdevice diff --git a/luasrc/controller/autotimeset.lua b/luasrc/controller/autotimeset.lua new file mode 100644 index 0000000..0cac4e2 --- /dev/null +++ b/luasrc/controller/autotimeset.lua @@ -0,0 +1,4 @@ +module("luci.controller.autotimeset",package.seeall) +function index() +entry({"admin","system","autotimeset"},cbi("autotimeset"),_("Scheduled Setting"),88) +end diff --git a/luasrc/model/cbi/autotimeset.lua b/luasrc/model/cbi/autotimeset.lua new file mode 100644 index 0000000..b19d6a2 --- /dev/null +++ b/luasrc/model/cbi/autotimeset.lua @@ -0,0 +1,47 @@ +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,"login","") +s.addremove=false +s.anonymous=true + +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.default=2 + +e=s:option(ListValue,"week",translate("Week Day")) +e:value(7,translate("Everyday")) +e:value(1,translate("Monday")) +e:value(2,translate("Tuesday")) +e:value(3,translate("Wednesday")) +e:value(4,translate("Thursday")) +e:value(5,translate("Friday")) +e:value(6,translate("Saturday")) +e:value(0,translate("Sunday")) +e.default=7 + +e=s:option(Value,"hour",translate("Hour")) +e.datatype = "range(0,23)" +e.rmempty = false + +e=s:option(Value,"minute",translate("Minute")) +e.datatype = "range(0,59)" +e.rmempty = false + +local e=luci.http.formvalue("cbi.apply") +if e then + io.popen("/etc/init.d/autotimeset restart") +end + +return m diff --git a/po/zh-cn/autotimeset.po b/po/zh-cn/autotimeset.po new file mode 100644 index 0000000..22e3889 --- /dev/null +++ b/po/zh-cn/autotimeset.po @@ -0,0 +1,30 @@ +msgid "Scheduled Setting" +msgstr "定时设置" + +msgid "Timing settings include: timing restart, timing shutdown, timing restart network, all functions can be used together." +msgstr "定时设置包括:定时重启、定时关机、定时重启网络,各功能可一起使用。" + +msgid "Scheduled Type" +msgstr "定时类型" + +msgid "Scheduled Reboot" +msgstr "定时重启机器" + +msgid "Scheduled Poweroff" +msgstr "定时关闭机器" + +msgid "Scheduled ReNetwork" +msgstr "定时重启网络" + +msgid "Week Day" +msgstr "设定星期" + +msgid "Everyday" +msgstr "每天" + +msgid "Hour" +msgstr "设定小时" + +msgid "Minute" +msgstr "设定分钟" + diff --git a/root/etc/config/autotimeset b/root/etc/config/autotimeset new file mode 100644 index 0000000..5d6eb5d --- /dev/null +++ b/root/etc/config/autotimeset @@ -0,0 +1,6 @@ +config login + option minute '1' + option hour '1' + option week '1' + option enable '0' + option stype '2' \ No newline at end of file diff --git a/root/etc/init.d/autotimeset b/root/etc/init.d/autotimeset new file mode 100644 index 0000000..9025162 --- /dev/null +++ b/root/etc/init.d/autotimeset @@ -0,0 +1,117 @@ +#!/bin/sh /etc/rc.common +#copyright by sirpdboy + +START=95 +STOP=10 + +run_poweroff() +{ + config_get_bool enable $1 enable + if [ $enable = 1 ] ; then + config_get stype $1 stype + config_get week $1 week + config_get minute $1 minute + config_get hour $1 hour + [ "$minute" -eq 0 ] && minute="00" + [ "$week" -eq 7 ] && week="*" + + if [ $stype = 1 ] ; then + local cmd="$minute $hour * * $week sleep 5 && touch /etc/banner && reboot" + if [ ! -f "/etc/crontabs/root" ] || [ $(cat /etc/crontabs/root | grep "$cmd" | wc -l) -eq 0 ]; then + sed -i '/reboot/d' /etc/crontabs/root >/dev/null 2>&1 + echo "$cmd" >> /etc/crontabs/root + + fi + echo "Auto REBOOT has started.." + + fi + if [ $stype = 2 ] ; then + local cmd="$minute $hour * * $week sleep 5 && touch /etc/banner && poweroff" + if [ ! -f "/etc/crontabs/root" ] || [ $(cat /etc/crontabs/root | grep "$cmd" | wc -l) -eq 0 ]; then + sed -i '/poweroff/d' /etc/crontabs/root >/dev/null 2>&1 + echo "$cmd" >> /etc/crontabs/root + + fi + echo "Auto poweroff has started.." + fi + if [ $stype = 3 ] ; then + local cmd="$minute $hour * * $week sleep 5 && touch /etc/banner && /etc/init.d/network restart" + if [ ! -f "/etc/crontabs/root" ] || [ $(cat /etc/crontabs/root | grep "$cmd" | wc -l) -eq 0 ]; then + sed -i '/network restart/d' /etc/crontabs/root >/dev/null 2>&1 + echo "$cmd" >> /etc/crontabs/root + + fi + echo "Auto network restart has started." + fi + else + del_cru + fi +} + + +add_cru() +{ + local enable=$(uci get autopoweroff.@login[0].enable) + if [ $enable = 1 ] ; then + local stype=$(uci get autopoweroff.@login[0].stype) + local week=$(uci get autopoweroff.@login[0].week) + local minute=$(uci get autopoweroff.@login[0].minute) + local hour=$(uci get autopoweroff.@login[0].hour) + if [ $stype = 1 ] ; then + local cmd="$minute $hour * * $week sleep 5 && touch /etc/banner && reboot" + if [ ! -f "/etc/crontabs/root" ] || [ $(cat /etc/crontabs/root | grep "$cmd" | wc -l) -eq 0 ]; then + sed -i '/reboot/d' /etc/crontabs/root >/dev/null 2>&1 + echo "$cmd" >> /etc/crontabs/root + + fi + echo "Auto REBOOT has started." + fi + if [ $stype = 2 ] ; then + local cmd="$minute $hour * * $week sleep 5 && touch /etc/banner && poweroff" + if [ ! -f "/etc/crontabs/root" ] || [ $(cat /etc/crontabs/root | grep "$cmd" | wc -l) -eq 0 ]; then + sed -i '/poweroff/d' /etc/crontabs/root >/dev/null 2>&1 + echo "$cmd" >> /etc/crontabs/root + + fi + echo "Auto poweroff has started." + fi + if [ $stype = 3 ] ; then + local cmd="$minute $hour * * $week sleep 5 && touch /etc/banner && /etc/init.d/network restart" + if [ ! -f "/etc/crontabs/root" ] || [ $(cat /etc/crontabs/root | grep "$cmd" | wc -l) -eq 0 ]; then + sed -i '/network restart/d' /etc/crontabs/root >/dev/null 2>&1 + echo "$cmd" >> /etc/crontabs/root + + fi + echo "Auto network restart has started." + fi + else + del_cru + fi +} + +start() +{ + config_load autopoweroff + config_foreach run_poweroff login + add_cru +} + +stop() +{ + del_cru + echo "Auto set has stop." +} + +del_cru() +{ + if [ -f "/etc/crontabs/root" ] && [ $(cat /etc/crontabs/root | grep reboot | wc -l) -ne 0 ]; then + sed -i '/reboot/d' /etc/crontabs/root >/dev/null 2>&1 + fi + if [ -f "/etc/crontabs/root" ] && [ $(cat /etc/crontabs/root | grep poweroff | wc -l) -ne 0 ]; then + sed -i '/poweroff/d' /etc/crontabs/root >/dev/null 2>&1 + fi + if [ -f "/etc/crontabs/root" ] && [ $(cat /etc/crontabs/root | grep network | wc -l) -ne 0 ]; then + sed -i '/network restart/d' /etc/crontabs/root >/dev/null 2>&1 + fi +} +