From 2915c44a11ca0ee40b51ff5d9c18a0da1951e170 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Thu, 16 May 2019 22:57:57 +0800 Subject: [PATCH] luci app zerotier: path bug fix --- package/lean/luci-app-zerotier/Makefile | 2 +- .../luasrc/controller/zerotier.lua | 9 +++- .../luasrc/model/cbi/zerotier.lua | 50 ------------------- .../luasrc/model/cbi/zerotier/info.lua | 15 ++++++ .../luasrc/model/cbi/zerotier/settings.lua | 26 ++++++++++ .../root/etc/init.d/zerotier | 6 ++- 6 files changed, 53 insertions(+), 55 deletions(-) delete mode 100644 package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier.lua create mode 100644 package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/info.lua create mode 100644 package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua diff --git a/package/lean/luci-app-zerotier/Makefile b/package/lean/luci-app-zerotier/Makefile index 9a4c4872e..4769dbccb 100644 --- a/package/lean/luci-app-zerotier/Makefile +++ b/package/lean/luci-app-zerotier/Makefile @@ -10,7 +10,7 @@ LUCI_TITLE:=LuCI for Zerotier LUCI_DEPENDS:=+zerotier LUCI_PKGARCH:=all PKG_VERSION:=1.0 -PKG_RELEASE:=13 +PKG_RELEASE:=15 include $(TOPDIR)/feeds/luci/luci.mk diff --git a/package/lean/luci-app-zerotier/luasrc/controller/zerotier.lua b/package/lean/luci-app-zerotier/luasrc/controller/zerotier.lua index fcbc28b68..e02a4f793 100644 --- a/package/lean/luci-app-zerotier/luasrc/controller/zerotier.lua +++ b/package/lean/luci-app-zerotier/luasrc/controller/zerotier.lua @@ -6,8 +6,13 @@ return end entry({"admin","vpn"}, firstchild(), "VPN", 45).dependent = false -entry({"admin","vpn","zerotier"},cbi("zerotier"),_("ZeroTier"),90).dependent=true -entry({"admin","vpn","zerotier","status"},call("act_status")).leaf=true + +entry({"admin", "vpn", "zerotier"},firstchild(), _("ZeroTier")).dependent = false + +entry({"admin", "vpn", "zerotier", "general"},cbi("zerotier/settings"), _("Base Setting"), 1) +entry({"admin", "vpn", "zerotier", "log"},form("zerotier/info"), _("Interface Info"), 2) + +entry({"admin","vpn","zerotier","status"},call("act_status")) end function act_status() diff --git a/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier.lua b/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier.lua deleted file mode 100644 index c63848981..000000000 --- a/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier.lua +++ /dev/null @@ -1,50 +0,0 @@ -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 is an open source, cross-platform and easy to use virtual LAN")) -a:section(SimpleSection).template = "zerotier/zerotier_status" - -t=a:section(NamedSection,"sample_config","zerotier") -t.anonymous=true -t.addremove=false - -t:tab("basic", translate("Base Setting")) - -e=t:taboption("basic", Flag,"enabled",translate("Enable")) -e.default=0 -e.rmempty=false - -e=t:taboption("basic", DynamicList,"join",translate('ZeroTier Network ID')) -e.password=true -e.rmempty=false - -e=t:taboption("basic", Flag,"nat",translate("Auto NAT Clients")) -e.default=0 -e.rmempty=false -e.description = translate("Allow zerotier clients access your LAN network") - -e=t:taboption("basic", DummyValue,"opennewwindow" , - translate("")) -e.description = translate("Create or manage your zerotier network, and auth clients who could access") - -local dog = "/tmp/zero.info" -t:tab("watchdog", translate("Interface Info")) -log = t:taboption("watchdog", TextValue, "sylogtext") -log.template = "cbi/tvalue" -log.rows = 8 -log.wrap = "off" -log.readonly="readonly" - -function log.cfgvalue(self, section) - luci.sys.exec("ifconfig $(ifconfig | grep zt | awk '{print $1}') > /tmp/zero.info") - return nixio.fs.readfile(dog) or "" -end - -function log.write(self, section, value) - value = value:gsub("\r\n?", "\n") - nixio.fs.writefile(dog, value) -end - -return a diff --git a/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/info.lua b/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/info.lua new file mode 100644 index 000000000..9bc3824cf --- /dev/null +++ b/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/info.lua @@ -0,0 +1,15 @@ +local fs = require "nixio.fs" +local conffile = "/tmp/zero.info" + +f = SimpleForm("logview") + +t = f:field(TextValue, "conf") +t.rmempty = true +t.rows = 15 +function t.cfgvalue() + luci.sys.exec("ifconfig $(ifconfig | grep zt | awk '{print $1}') > /tmp/zero.info") + return fs.readfile(conffile) or "" +end +t.readonly="readonly" + +return f \ No newline at end of file diff --git a/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua b/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua new file mode 100644 index 000000000..14f4bdce0 --- /dev/null +++ b/package/lean/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua @@ -0,0 +1,26 @@ + +a=Map("zerotier",translate("ZeroTier"),translate("Zerotier is an open source, cross-platform and easy to use virtual LAN")) +a:section(SimpleSection).template = "zerotier/zerotier_status" + +t=a:section(NamedSection,"sample_config","zerotier") +t.anonymous=true +t.addremove=false + +e=t:option(Flag,"enabled",translate("Enable")) +e.default=0 +e.rmempty=false + +e=t:option(DynamicList,"join",translate('ZeroTier Network ID')) +e.password=true +e.rmempty=false + +e=t:option(Flag,"nat",translate("Auto NAT Clients")) +e.default=0 +e.rmempty=false +e.description = translate("Allow zerotier clients access your LAN network") + +e=t:option(DummyValue,"opennewwindow" , + translate("")) +e.description = translate("Create or manage your zerotier network, and auth clients who could access") + +return a diff --git a/package/lean/luci-app-zerotier/root/etc/init.d/zerotier b/package/lean/luci-app-zerotier/root/etc/init.d/zerotier index 7acbc6e8e..bb0fe92e7 100755 --- a/package/lean/luci-app-zerotier/root/etc/init.d/zerotier +++ b/package/lean/luci-app-zerotier/root/etc/init.d/zerotier @@ -21,8 +21,10 @@ start_instance() { echo "disabled in config" return 1 fi - - config_get config_path $cfg 'config_path' + + [ -d /etc/config/zero ] || mkdir -p /etc/config/zero + config_path=/etc/config/zero + config_get_bool port $cfg 'port' config_get secret $cfg 'secret'