autopowroff1.3 net1.26

This commit is contained in:
sirpdboy 2021-02-08 03:08:11 +08:00
parent 79794529c2
commit 419b7a0cd3
10 changed files with 263 additions and 2 deletions

View File

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

View File

@ -0,0 +1,19 @@
# Copyright (C) 2019 sirpdboy <https://github.com/sirpdboy/luci-app-autopoweroff/>
#
# 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 <https://github.com/sirpdboy/luci-app-autopoweroff/>
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,22 @@
luci-app-autopoweroff for OpenWRT/Lede(中文)
源码地址 https://github.com/sirpdboy/luci-app-autopoweroff
定时重启关机二合一升级版。
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

View File

@ -0,0 +1,4 @@
module("luci.controller.autopoweroff",package.seeall)
function index()
entry({"admin","system","autopoweroff"},cbi("autopoweroff"),_("Scheduled Setting"),88)
end

View File

@ -0,0 +1,46 @@
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("autopoweroff",translate("Scheduled Setting"),translate("Scheduled reboot poweroff Setting"))
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.default=1
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/autopoweroff restart")
end
return m

View File

@ -0,0 +1,26 @@
msgid "Scheduled Setting"
msgstr "定时设置"
msgid "Scheduled reboot poweroff Setting"
msgstr "定时重启关机二合一设置,启用后可以同时设置一次自动重启和一次自动关机。"
msgid "Scheduled Type"
msgstr "定时类型"
msgid "Scheduled Reboot"
msgstr "定时重启"
msgid "Scheduled Poweroff"
msgstr "定时关机"
msgid "Week Day"
msgstr "设定星期"
msgid "Everyday"
msgstr "每天"
msgid "Hour"
msgstr "设定小时"
msgid "Minute"
msgstr "设定分钟"

View File

@ -0,0 +1,21 @@
luci-app-autopoweroff for OpenWRT/Lede(ÖÐÎÄ)
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

View File

@ -0,0 +1,6 @@
config login
option minute '1'
option hour '1'
option week '1'
option enable '0'
option stype '1'

View File

@ -0,0 +1,96 @@
#!/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
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
else
del_cru
fi
}
start()
{
config_load autopoweroff
config_foreach run_poweroff login
add_cru
}
stop()
{
del_cru
echo "Auto poweroff 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
}

View File

@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=netdata
PKG_VERSION:=1.29.0
PKG_VERSION:=1.26.0
PKG_RELEASE:=1
PKG_MAINTAINER:=Josef Schlehofer <pepe.schlehofer@gmail.com>, Daniel Engberg <daniel.engberg.lists@pyret.net>
@ -18,7 +18,7 @@ PKG_CPE_ID:=cpe:/a:my-netdata:netdata
PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/netdata/netdata/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=31d68c983d75e7d4e4c1d9e360ac4030d55f1362
PKG_HASH:=be32d49381da39196574011653ea863f2064a2168bc9b61a1354171b27ce370b
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1