mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-19 14:13:30 +00:00
re-add luci app zerotier
This commit is contained in:
parent
78f10fee00
commit
f5ca587a61
19
package/lean/luci-app-zerotier/Makefile
Normal file
19
package/lean/luci-app-zerotier/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
#
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI for Zerotier
|
||||
LUCI_DEPENDS:=+zerotier
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=3
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
|
@ -0,0 +1,17 @@
|
||||
module("luci.controller.zerotier",package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/zerotier")then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin","services","zerotier"},cbi("zerotier"),_("ZeroTier"),90).dependent=true
|
||||
entry({"admin","services","zerotier","status"},call("act_status")).leaf=true
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("pgrep /usr/bin/zerotier-one >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
32
package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier.lua
Normal file
32
package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier.lua
Normal file
@ -0,0 +1,32 @@
|
||||
local e=require"nixio.fs"
|
||||
local e=luci.http
|
||||
local o=require"luci.model.network".init()
|
||||
local a,t,e,b
|
||||
a=Map("zerotier",translate("ZeroTier"),translate("ZeroTier 是一款可以创建P2P虚拟局域网的开源软件。"))
|
||||
a:section(SimpleSection).template = "zerotier/zerotier_status"
|
||||
t=a:section(NamedSection,"sample_config","zerotier",translate("全局设置"))
|
||||
t.anonymous=true
|
||||
t.addremove=false
|
||||
e=t:option(Flag,"enabled",translate("启用"))
|
||||
e.default=0
|
||||
e.rmempty=false
|
||||
e=t:option(ListValue,"interface",translate("接口"))
|
||||
for b,t in ipairs(o:get_networks())do
|
||||
if t:name()~="loopback" then e:value(t:name())end
|
||||
end
|
||||
-- e=t:option(Value,"start_delay",translate("延时启动"),translate("Units:seconds"))
|
||||
-- e.datatype="uinteger"
|
||||
-- e.default="0"
|
||||
-- e.rmempty=true
|
||||
e=t:option(DynamicList,"join",translate('ZeroTier 网络 ID'))
|
||||
e.password=true
|
||||
e.rmempty=false
|
||||
if nixio.fs.access("/etc/config/zerotier")then
|
||||
e=t:option(Button,"Configuration",translate("网络配置管理"))
|
||||
e.inputtitle=translate("打开网站")
|
||||
e.inputstyle="reload"
|
||||
e.write=function()
|
||||
luci.http.redirect("https://my.zerotier.com/")
|
||||
end
|
||||
end
|
||||
return a
|
@ -0,0 +1,23 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[zerotier]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('zerotier_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green><%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red><%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Running Status%></legend>
|
||||
<p id="zerotier_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
11
package/lean/luci-app-zerotier/root/etc/uci-defaults/40_luci-zerotier
Executable file
11
package/lean/luci-app-zerotier/root/etc/uci-defaults/40_luci-zerotier
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@zerotier[-1]
|
||||
add ucitrack zerotier
|
||||
set ucitrack.@zerotier[-1].init=zerotier
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user