mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-05 18:44:03 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,16 @@
|
||||
# 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 Timewol
|
||||
LUCI_DEPENDS:=+etherwake
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
@@ -0,0 +1,16 @@
|
||||
module("luci.controller.timewol", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/timewol") then return end
|
||||
|
||||
entry({"admin", "control"}, firstchild(), "Control", 44).dependent = false
|
||||
entry({"admin", "control", "timewol"}, cbi("timewol"), _("Timed Wakeup"), 95).dependent = true
|
||||
entry({"admin", "control", "timewol", "status"}, call("status")).leaf = true
|
||||
end
|
||||
|
||||
function status()
|
||||
local e = {}
|
||||
e.status = luci.sys.call("cat /etc/crontabs/root | grep etherwake >/dev/null") == 0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
@@ -0,0 +1,38 @@
|
||||
local i = require "luci.sys"
|
||||
|
||||
t = Map("timewol", translate("Timed network wake-up"), translate("Wake up your LAN device regularly"))
|
||||
|
||||
e = t:section(TypedSection, "basic", translate("Basic setting"))
|
||||
e.anonymous = true
|
||||
|
||||
o = e:option(Flag, "enable", translate("Enable"))
|
||||
o.rmempty = false
|
||||
|
||||
e = t:section(TypedSection, "macclient", translate("Client setting"))
|
||||
e.template = "cbi/tblsection"
|
||||
e.anonymous = true
|
||||
e.addremove = true
|
||||
|
||||
nolimit_mac = e:option(Value, "macaddr", translate("MAC Address"))
|
||||
nolimit_mac.rmempty = false
|
||||
i.net.mac_hints(function(e, t) nolimit_mac:value(e, "%s (%s)" % {e, t}) end)
|
||||
nolimit_eth = e:option(Value, "maceth", translate("Network interface"))
|
||||
nolimit_eth.rmempty = false
|
||||
for t, e in ipairs(i.net.devices()) do if e ~= "lo" then nolimit_eth:value(e) end end
|
||||
|
||||
a = e:option(Value, "minute", translate("minutes"))
|
||||
a.optional = false
|
||||
|
||||
a = e:option(Value, "hour", translate("hour"))
|
||||
a.optional = false
|
||||
|
||||
a = e:option(Value, "day", translate("day"))
|
||||
a.optional = false
|
||||
|
||||
a = e:option(Value, "month", translate("month"))
|
||||
a.optional = false
|
||||
|
||||
a = e:option(Value, "weeks", translate("weeks"))
|
||||
a.optional = false
|
||||
|
||||
return t
|
||||
@@ -0,0 +1,18 @@
|
||||
<%#
|
||||
Copyright 2016 Chen RuiWei <crwbak@gmail.com>
|
||||
Licensed to the public under the Apache License 2.0.
|
||||
-%>
|
||||
|
||||
<% include("cbi/map") %>
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(2, '<%=luci.dispatcher.build_url("admin", "control", "timewol", "status")%>', null,
|
||||
function(x, result)
|
||||
{
|
||||
var status = document.getElementsByClassName('timewol_status')[0];
|
||||
status.setAttribute("style","font-weight:bold;");
|
||||
status.setAttribute("color",result.status ? "green":"red");
|
||||
status.innerHTML = result.status?'<%=translate("RUNNING")%>':'<%=translate("NOT RUNNING")%>';
|
||||
}
|
||||
)
|
||||
//]]>
|
||||
</script>
|
||||
@@ -0,0 +1,3 @@
|
||||
<%+cbi/valueheader%>
|
||||
<font class="timewol_status"><%=pcdata(self:cfgvalue(section) or self.default or "")%></font>
|
||||
<%+cbi/valuefooter%>
|
||||
@@ -0,0 +1,53 @@
|
||||
msgid "Control"
|
||||
msgstr "管控"
|
||||
|
||||
msgid "Running Status"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "Collecting data..."
|
||||
msgstr "正在收集数据..."
|
||||
|
||||
msgid "NOT RUNNING"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "RUNNING"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "Timed Wakeup"
|
||||
msgstr "定时唤醒"
|
||||
|
||||
msgid "Timed network wake-up"
|
||||
msgstr "定时网络唤醒"
|
||||
|
||||
msgid "Wake up your LAN device regularly"
|
||||
msgstr "定时唤醒你的局域网设备"
|
||||
|
||||
msgid "Basic setting"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "开启"
|
||||
|
||||
msgid "Client setting"
|
||||
msgstr "客户端设置"
|
||||
|
||||
msgid "MAC Address"
|
||||
msgstr "MAC 地址"
|
||||
|
||||
msgid "Network interface"
|
||||
msgstr "网络接口"
|
||||
|
||||
msgid "minutes"
|
||||
msgstr "分钟"
|
||||
|
||||
msgid "hour"
|
||||
msgstr "小时"
|
||||
|
||||
msgid "day"
|
||||
msgstr "日"
|
||||
|
||||
msgid "month"
|
||||
msgstr "月"
|
||||
|
||||
msgid "weeks"
|
||||
msgstr "星期"
|
||||
+1
@@ -0,0 +1 @@
|
||||
zh-cn
|
||||
@@ -0,0 +1,3 @@
|
||||
|
||||
config basic
|
||||
option enable '0'
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2015 OpenWrt-dist
|
||||
# Copyright (C) 2016 fw867 <ffkykzs@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
START=99
|
||||
|
||||
CONFIG=timewol
|
||||
|
||||
uci_get_by_type() {
|
||||
local index=0
|
||||
if [ -n $4 ]; then
|
||||
index=$4
|
||||
fi
|
||||
local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null)
|
||||
echo ${ret:=$3}
|
||||
}
|
||||
|
||||
is_true() {
|
||||
case $1 in
|
||||
1|on|true|yes|enabled) echo 0;;
|
||||
*) echo 1;;
|
||||
esac
|
||||
}
|
||||
|
||||
load_config() {
|
||||
ENABLED=$(uci_get_by_type basic enable)
|
||||
return $(is_true $ENABLED)
|
||||
}
|
||||
|
||||
add_rule(){
|
||||
local items=$(uci show ${CONFIG} | grep "=macclient" | cut -d '.' -sf 2 | cut -d '=' -sf 1)
|
||||
for i in $items; do
|
||||
local macaddr=$(uci -q get ${CONFIG}.${i}.macaddr)
|
||||
local maceth=$(uci -q get ${CONFIG}.${i}.maceth)
|
||||
local minute=$(uci -q get ${CONFIG}.${i}.minute)
|
||||
local hour=$(uci -q get ${CONFIG}.${i}.hour)
|
||||
local day=$(uci -q get ${CONFIG}.${i}.day)
|
||||
local month=$(uci -q get ${CONFIG}.${i}.month)
|
||||
local weeks=$(uci -q get ${CONFIG}.${i}.weeks)
|
||||
if [ -z $macaddr ] || [ -z $maceth ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -z $minute ] ; then
|
||||
minute="0"
|
||||
fi
|
||||
if [ -z $hour ] ; then
|
||||
hour="*"
|
||||
fi
|
||||
if [ -z $day ] ; then
|
||||
day="*"
|
||||
fi
|
||||
if [ -z $month ] ; then
|
||||
month="*"
|
||||
fi
|
||||
if [ -z $weeks ] ; then
|
||||
weeks="*"
|
||||
fi
|
||||
echo "$minute $hour $day $month $weeks /usr/bin/etherwake -D -i $maceth $macaddr" >> /etc/crontabs/root
|
||||
unset macaddr maceth minute hour day month weeks
|
||||
done
|
||||
}
|
||||
|
||||
start() {
|
||||
stop
|
||||
! load_config && exit 0
|
||||
add_rule
|
||||
}
|
||||
stop() {
|
||||
sed -i '/etherwake/d' /etc/crontabs/root >/dev/null 2>&1
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#!/bin/sh
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-timewol.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-timewol.json << EEOF
|
||||
{
|
||||
"config": "timewol",
|
||||
"init": "timewol"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@timewol[-1]
|
||||
add ucitrack timewol
|
||||
set ucitrack.@timewol[-1].init=timewol
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-control-timewol": {
|
||||
"description": "Grant UCI access for luci-app-control-timewol",
|
||||
"read": {
|
||||
"uci": [ "timewol" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "timewol" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"config": "timewol",
|
||||
"init": "timewol"
|
||||
}
|
||||
Reference in new issue
Block a user