luci-app-ddns: update to support ddns-scripts 2.7.6
needed changes to support ddns-scripts 2.7.6 - new command line options of dynamic_ddns_lucihelper.sh - renamed global config options - new location of services files Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
This commit is contained in:
parent
1fd43b4b65
commit
475b74b9bf
9 changed files with 103 additions and 83 deletions
|
@ -1,16 +1,18 @@
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008-2016 The LuCI Team <luci@lists.subsignal.org>
|
# Copyright 2008 Steven Barth <steven@midlink.org>
|
||||||
#
|
# Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
||||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
# Copyright 2013 Manuel Munz <freifunk at somakoma dot de>
|
||||||
|
# Copyright 2014-2016 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||||
#
|
#
|
||||||
|
# This is free software, licensed under the Apache License, Version 2.0
|
||||||
|
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-ddns
|
# PKG_NAME:=luci-app-ddns
|
||||||
|
|
||||||
# Version == major.minor.patch
|
# Version == major.minor.patch
|
||||||
# increase on new functionality (minor) or patches (patch)
|
# increase on new functionality (minor) or patches (patch)
|
||||||
PKG_VERSION:=2.4.7
|
PKG_VERSION:=2.4.8
|
||||||
|
|
||||||
# Release == build
|
# Release == build
|
||||||
# increase on changes of translation files
|
# increase on changes of translation files
|
||||||
|
@ -22,15 +24,13 @@ PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>
|
||||||
# LuCI specific settings
|
# LuCI specific settings
|
||||||
LUCI_TITLE:=LuCI Support for Dynamic DNS Client (ddns-scripts)
|
LUCI_TITLE:=LuCI Support for Dynamic DNS Client (ddns-scripts)
|
||||||
LUCI_DEPENDS:=+luci-mod-admin-full +ddns-scripts
|
LUCI_DEPENDS:=+luci-mod-admin-full +ddns-scripts
|
||||||
LUCI_PKGARCH:=all
|
# LUCI_PKGARCH:=all
|
||||||
|
|
||||||
define Package/$(PKG_NAME)/config
|
define Package/$(PKG_NAME)/config
|
||||||
# shown in make menuconfig <Help>
|
# shown in make menuconfig <Help>
|
||||||
help
|
help
|
||||||
$(LUCI_TITLE)
|
$(LUCI_TITLE)
|
||||||
.
|
|
||||||
Version: $(PKG_VERSION)-$(PKG_RELEASE)
|
Version: $(PKG_VERSION)-$(PKG_RELEASE)
|
||||||
$(PKG_MAINTAINER)
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
include ../../luci.mk
|
include ../../luci.mk
|
||||||
|
|
|
@ -17,12 +17,14 @@ local UCI = require "luci.model.uci"
|
||||||
local UTIL = require "luci.util"
|
local UTIL = require "luci.util"
|
||||||
local DDNS = require "luci.tools.ddns" -- ddns multiused functions
|
local DDNS = require "luci.tools.ddns" -- ddns multiused functions
|
||||||
|
|
||||||
|
luci_helper = "/usr/lib/ddns/dynamic_dns_lucihelper.sh"
|
||||||
|
|
||||||
local srv_name = "ddns-scripts"
|
local srv_name = "ddns-scripts"
|
||||||
local srv_ver_min = "2.7.5" -- minimum version of service required
|
local srv_ver_min = "2.7.6" -- minimum version of service required
|
||||||
local srv_ver_cmd = [[/usr/lib/ddns/dynamic_dns_updater.sh --version | awk {'print $2'}]]
|
local srv_ver_cmd = luci_helper .. [[ -V | awk {'print $2'}]]
|
||||||
local app_name = "luci-app-ddns"
|
local app_name = "luci-app-ddns"
|
||||||
local app_title = "Dynamic DNS"
|
local app_title = "Dynamic DNS"
|
||||||
local app_version = "2.4.7-1"
|
local app_version = "2.4.8-1"
|
||||||
|
|
||||||
function index()
|
function index()
|
||||||
local nxfs = require "nixio.fs" -- global definitions not available
|
local nxfs = require "nixio.fs" -- global definitions not available
|
||||||
|
@ -96,14 +98,14 @@ function app_title_main()
|
||||||
end
|
end
|
||||||
function service_version()
|
function service_version()
|
||||||
local ver = nil
|
local ver = nil
|
||||||
|
|
||||||
|
ver = UTIL.exec(srv_ver_cmd)
|
||||||
|
if #ver > 0 then return ver end
|
||||||
|
|
||||||
IPKG.list_installed(srv_name, function(n, v, d)
|
IPKG.list_installed(srv_name, function(n, v, d)
|
||||||
if v and (#v > 0) then ver = v end
|
if v and (#v > 0) then ver = v end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
if not ver or (#ver == 0) then
|
|
||||||
ver = UTIL.exec(srv_ver_cmd)
|
|
||||||
if #ver == 0 then ver = nil end
|
|
||||||
end
|
|
||||||
return ver
|
return ver
|
||||||
end
|
end
|
||||||
function service_ok()
|
function service_ok()
|
||||||
|
@ -191,10 +193,14 @@ local function _get_status()
|
||||||
local force_ipversion = tonumber(s["force_ipversion"] or 0)
|
local force_ipversion = tonumber(s["force_ipversion"] or 0)
|
||||||
local force_dnstcp = tonumber(s["force_dnstcp"] or 0)
|
local force_dnstcp = tonumber(s["force_dnstcp"] or 0)
|
||||||
local is_glue = tonumber(s["is_glue"] or 0)
|
local is_glue = tonumber(s["is_glue"] or 0)
|
||||||
local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh]]
|
local command = luci_helper .. [[ -]]
|
||||||
command = command .. [[ get_registered_ip ]] .. lookup_host .. [[ ]] .. use_ipv6 ..
|
if (use_ipv6 == 1) then command = command .. [[6]] end
|
||||||
[[ ]] .. force_ipversion .. [[ ]] .. force_dnstcp ..
|
if (force_ipversion == 1) then command = command .. [[f]] end
|
||||||
[[ ]] .. is_glue .. [[ ]] .. dnsserver
|
if (force_dnstcp == 1) then command = command .. [[t]] end
|
||||||
|
if (is_glue == 1) then command = command .. [[g]] end
|
||||||
|
command = command .. [[l ]] .. lookup_host
|
||||||
|
if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end
|
||||||
|
command = command .. [[ -- get_registered_ip]]
|
||||||
local reg_ip = SYS.exec(command)
|
local reg_ip = SYS.exec(command)
|
||||||
if reg_ip == "" then
|
if reg_ip == "" then
|
||||||
reg_ip = "_nodata_"
|
reg_ip = "_nodata_"
|
||||||
|
@ -221,8 +227,8 @@ end
|
||||||
function logread(section)
|
function logread(section)
|
||||||
-- read application settings
|
-- read application settings
|
||||||
local uci = UCI.cursor()
|
local uci = UCI.cursor()
|
||||||
local log_dir = uci:get("ddns", "global", "log_dir") or "/var/log/ddns"
|
local ldir = uci:get("ddns", "global", "ddns_logdir") or "/var/log/ddns"
|
||||||
local lfile = log_dir .. "/" .. section .. ".log"
|
local lfile = ldir .. "/" .. section .. ".log"
|
||||||
local ldata = NXFS.readfile(lfile)
|
local ldata = NXFS.readfile(lfile)
|
||||||
|
|
||||||
if not ldata or #ldata == 0 then
|
if not ldata or #ldata == 0 then
|
||||||
|
@ -289,8 +295,9 @@ function startstop(section, enabled)
|
||||||
uci:commit("ddns")
|
uci:commit("ddns")
|
||||||
uci:unload("ddns")
|
uci:unload("ddns")
|
||||||
|
|
||||||
-- start dynamic_dns_updater.sh script
|
-- start ddns-updater for section
|
||||||
os.execute ([[/usr/lib/ddns/dynamic_dns_updater.sh %s 0 > /dev/null 2>&1 &]] % section)
|
local command = luci_helper .. [[ -S ]] .. section .. [[ -- start]]
|
||||||
|
os.execute(command)
|
||||||
NX.nanosleep(3) -- 3 seconds "show time"
|
NX.nanosleep(3) -- 3 seconds "show time"
|
||||||
|
|
||||||
-- status changed so return full status
|
-- status changed so return full status
|
||||||
|
|
|
@ -58,7 +58,7 @@ end
|
||||||
|
|
||||||
-- read services/services_ipv6 files -- ########################################
|
-- read services/services_ipv6 files -- ########################################
|
||||||
local services4 = { } -- IPv4 --
|
local services4 = { } -- IPv4 --
|
||||||
local fd4 = io.open("/usr/lib/ddns/services", "r")
|
local fd4 = io.open("/etc/ddns/services", "r")
|
||||||
if fd4 then
|
if fd4 then
|
||||||
local ln, s, t
|
local ln, s, t
|
||||||
repeat
|
repeat
|
||||||
|
@ -72,7 +72,7 @@ if fd4 then
|
||||||
end
|
end
|
||||||
|
|
||||||
local services6 = { } -- IPv6 --
|
local services6 = { } -- IPv6 --
|
||||||
local fd6 = io.open("/usr/lib/ddns/services_ipv6", "r")
|
local fd6 = io.open("/etc/ddns/services_ipv6", "r")
|
||||||
if fd6 then
|
if fd6 then
|
||||||
local ln, s, t
|
local ln, s, t
|
||||||
repeat
|
repeat
|
||||||
|
@ -91,35 +91,38 @@ end
|
||||||
-- local IP can be read
|
-- local IP can be read
|
||||||
local function _verify_ip_source()
|
local function _verify_ip_source()
|
||||||
-- section is globally defined here be calling agrument (see above)
|
-- section is globally defined here be calling agrument (see above)
|
||||||
local _network = "-"
|
local _arg
|
||||||
local _url = "-"
|
|
||||||
local _interface = "-"
|
|
||||||
local _script = "-"
|
|
||||||
local _proxy = ""
|
|
||||||
|
|
||||||
local _ipv6 = usev6:formvalue(section)
|
local _ipv6 = usev6:formvalue(section)
|
||||||
local _source = (_ipv6 == "1")
|
local _source = (_ipv6 == "1")
|
||||||
and src6:formvalue(section)
|
and src6:formvalue(section)
|
||||||
or src4:formvalue(section)
|
or src4:formvalue(section)
|
||||||
|
|
||||||
|
local command = CTRL.luci_helper .. [[ -]]
|
||||||
|
if (_ipv6 == "1") then command = command .. [[6]] end
|
||||||
|
|
||||||
if _source == "network" then
|
if _source == "network" then
|
||||||
_network = (_ipv6 == "1")
|
_arg = (_ipv6 == "1")
|
||||||
and ipn6:formvalue(section)
|
and ipn6:formvalue(section)
|
||||||
or ipn4:formvalue(section)
|
or ipn4:formvalue(section)
|
||||||
|
command = command .. [[n ]] .. _arg
|
||||||
elseif _source == "web" then
|
elseif _source == "web" then
|
||||||
_url = (_ipv6 == "1")
|
_arg = (_ipv6 == "1")
|
||||||
and iurl6:formvalue(section)
|
and iurl6:formvalue(section)
|
||||||
or iurl4:formvalue(section)
|
or iurl4:formvalue(section)
|
||||||
-- proxy only needed for checking url
|
command = command .. [[u ]] .. _arg
|
||||||
_proxy = (pxy) and pxy:formvalue(section) or ""
|
|
||||||
elseif _source == "interface" then
|
|
||||||
_interface = ipi:formvalue(section)
|
|
||||||
elseif _source == "script" then
|
|
||||||
_script = ips:formvalue(section)
|
|
||||||
end
|
|
||||||
|
|
||||||
local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh get_local_ip ]] ..
|
-- proxy only needed for checking url
|
||||||
_ipv6 .. [[ ]] .. _source .. [[ ]] .. _network .. [[ ]] ..
|
_arg = (pxy) and pxy:formvalue(section) or ""
|
||||||
_url .. [[ ]] .. _interface .. [[ ']] .. _script.. [[' ]] .. _proxy
|
if (_arg and #_arg > 0) then
|
||||||
|
command = command .. [[ -p ]] .. _arg
|
||||||
|
end
|
||||||
|
elseif _source == "interface" then
|
||||||
|
command = command .. [[i ]] .. ipi:formvalue(section)
|
||||||
|
elseif _source == "script" then
|
||||||
|
command = command .. [[s ]] .. ips:formvalue(section)
|
||||||
|
end
|
||||||
|
command = command .. [[ -- get_local_ip]]
|
||||||
return (SYS.call(command) == 0)
|
return (SYS.call(command) == 0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -248,10 +251,8 @@ if m:formvalue("cbid.ddns.%s._switch" % section) then -- section == arg[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- read application settings -- ################################################
|
-- read application settings -- ################################################
|
||||||
-- date format; if not set use ISO format
|
|
||||||
local date_format = m.uci:get(m.config, "global", "date_format") or "%F %R"
|
|
||||||
-- log directory
|
-- log directory
|
||||||
local log_dir = m.uci:get(m.config, "global", "log_dir") or "/var/log/ddns"
|
local logdir = m.uci:get(m.config, "global", "ddns_logdir") or "/var/log/ddns"
|
||||||
|
|
||||||
-- cbi-section definition -- ###################################################
|
-- cbi-section definition -- ###################################################
|
||||||
local ns = m:section( NamedSection, section, "service",
|
local ns = m:section( NamedSection, section, "service",
|
||||||
|
@ -1158,8 +1159,11 @@ if DDNS.has_dnsserver or ( ( m:get(section, "dns_server") or "" ) ~= "" ) then
|
||||||
else
|
else
|
||||||
local ipv6 = usev6:formvalue(section) or "0"
|
local ipv6 = usev6:formvalue(section) or "0"
|
||||||
local force = fipv:formvalue(section) or "0"
|
local force = fipv:formvalue(section) or "0"
|
||||||
local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh verify_dns ]] ..
|
local command = CTRL.luci_helper .. [[ -]]
|
||||||
value .. [[ ]] .. ipv6 .. [[ ]] .. force
|
if (ipv6 == 1) then command = command .. [[6]] end
|
||||||
|
if (force == 1) then command = command .. [[f]] end
|
||||||
|
command = command .. [[d ]] .. value .. [[ -- verify_dns]]
|
||||||
|
|
||||||
local ret = SYS.call(command)
|
local ret = SYS.call(command)
|
||||||
if ret == 0 then return value -- everything OK
|
if ret == 0 then return value -- everything OK
|
||||||
elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host")
|
elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host")
|
||||||
|
@ -1225,8 +1229,10 @@ if DDNS.has_proxy or ( ( m:get(section, "proxy") or "" ) ~= "" ) then
|
||||||
elseif DDNS.has_proxy then
|
elseif DDNS.has_proxy then
|
||||||
local ipv6 = usev6:formvalue(section) or "0"
|
local ipv6 = usev6:formvalue(section) or "0"
|
||||||
local force = fipv:formvalue(section) or "0"
|
local force = fipv:formvalue(section) or "0"
|
||||||
local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh verify_proxy ]] ..
|
local command = CRTL.luci_helper .. [[ -]]
|
||||||
value .. [[ ]] .. ipv6 .. [[ ]] .. force
|
if (ipv6 == 1) then command = command .. [[6]] end
|
||||||
|
if (force == 1) then command = command .. [[f]] end
|
||||||
|
command = command .. [[p ]] .. value .. [[ -- verify_proxy]]
|
||||||
local ret = SYS.call(command)
|
local ret = SYS.call(command)
|
||||||
if ret == 0 then return value
|
if ret == 0 then return value
|
||||||
elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host")
|
elseif ret == 2 then return nil, err_tab_adv(self) .. translate("nslookup can not resolve host")
|
||||||
|
@ -1262,7 +1268,7 @@ end
|
||||||
logf = ns:taboption("advanced", Flag, "use_logfile",
|
logf = ns:taboption("advanced", Flag, "use_logfile",
|
||||||
translate("Log to file"),
|
translate("Log to file"),
|
||||||
translate("Writes detailed messages to log file. File will be truncated automatically.") .. "<br />" ..
|
translate("Writes detailed messages to log file. File will be truncated automatically.") .. "<br />" ..
|
||||||
translate("File") .. [[: "]] .. log_dir .. [[/]] .. section .. [[.log"]] )
|
translate("File") .. [[: "]] .. logdir .. [[/]] .. section .. [[.log"]] )
|
||||||
logf.orientation = "horizontal"
|
logf.orientation = "horizontal"
|
||||||
logf.default = "1" -- if not defined write to log by default
|
logf.default = "1" -- if not defined write to log by default
|
||||||
|
|
||||||
|
@ -1464,7 +1470,7 @@ lv.template = "ddns/detail_logview"
|
||||||
lv.inputtitle = translate("Read / Reread log file")
|
lv.inputtitle = translate("Read / Reread log file")
|
||||||
lv.rows = 50
|
lv.rows = 50
|
||||||
function lv.cfgvalue(self, section)
|
function lv.cfgvalue(self, section)
|
||||||
local lfile=log_dir .. "/" .. section .. ".log"
|
local lfile=logdir .. "/" .. section .. ".log"
|
||||||
if NXFS.access(lfile) then
|
if NXFS.access(lfile) then
|
||||||
return lfile .. "\n" .. translate("Please press [Read] button")
|
return lfile .. "\n" .. translate("Please press [Read] button")
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,8 @@ m.redirect = DISP.build_url("admin", "services", "ddns")
|
||||||
|
|
||||||
function m.commit_handler(self)
|
function m.commit_handler(self)
|
||||||
if self.changed then -- changes ?
|
if self.changed then -- changes ?
|
||||||
os.execute("/etc/init.d/ddns reload &") -- reload configuration
|
local command = CTRL.luci_helper .. " -- reload"
|
||||||
|
os.execute(command) -- reload configuration
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,8 +41,8 @@ function ns.cfgvalue(self, section)
|
||||||
return self.map:get(section)
|
return self.map:get(section)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- allow_local_ip -- ##########################################################
|
-- upd_privateip -- ###########################################################
|
||||||
local ali = ns:option(Flag, "allow_local_ip")
|
local ali = ns:option(Flag, "upd_privateip")
|
||||||
ali.title = translate("Allow non-public IP's")
|
ali.title = translate("Allow non-public IP's")
|
||||||
ali.description = translate("Non-public and by default blocked IP's") .. ":"
|
ali.description = translate("Non-public and by default blocked IP's") .. ":"
|
||||||
.. [[<br /><strong>IPv4: </strong>]]
|
.. [[<br /><strong>IPv4: </strong>]]
|
||||||
|
@ -50,8 +51,8 @@ ali.description = translate("Non-public and by default blocked IP's") .. ":"
|
||||||
.. "::/32, f000::/4"
|
.. "::/32, f000::/4"
|
||||||
ali.default = "0"
|
ali.default = "0"
|
||||||
|
|
||||||
-- date_format -- #############################################################
|
-- ddns_dateformat -- #########################################################
|
||||||
local df = ns:option(Value, "date_format")
|
local df = ns:option(Value, "ddns_dateformat")
|
||||||
df.title = translate("Date format")
|
df.title = translate("Date format")
|
||||||
df.description = [[<a href="http://www.cplusplus.com/reference/ctime/strftime/" target="_blank">]]
|
df.description = [[<a href="http://www.cplusplus.com/reference/ctime/strftime/" target="_blank">]]
|
||||||
.. translate("For supported codes look here")
|
.. translate("For supported codes look here")
|
||||||
|
@ -69,8 +70,8 @@ function df.parse(self, section, novld)
|
||||||
DDNS.value_parse(self, section, novld)
|
DDNS.value_parse(self, section, novld)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- run_dir -- #################################################################
|
-- ddns_rundir -- #############################################################
|
||||||
local rd = ns:option(Value, "run_dir")
|
local rd = ns:option(Value, "ddns_rundir")
|
||||||
rd.title = translate("Status directory")
|
rd.title = translate("Status directory")
|
||||||
rd.description = translate("Directory contains PID and other status information for each running section")
|
rd.description = translate("Directory contains PID and other status information for each running section")
|
||||||
rd.default = "/var/run/ddns"
|
rd.default = "/var/run/ddns"
|
||||||
|
@ -79,8 +80,8 @@ function rd.parse(self, section, novld)
|
||||||
DDNS.value_parse(self, section, novld)
|
DDNS.value_parse(self, section, novld)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- log_dir -- #################################################################
|
-- ddns_logdir -- #############################################################
|
||||||
local ld = ns:option(Value, "log_dir")
|
local ld = ns:option(Value, "ddns_logdir")
|
||||||
ld.title = translate("Log directory")
|
ld.title = translate("Log directory")
|
||||||
ld.description = translate("Directory contains Log files for each running section")
|
ld.description = translate("Directory contains Log files for each running section")
|
||||||
ld.default = "/var/log/ddns"
|
ld.default = "/var/log/ddns"
|
||||||
|
@ -89,8 +90,8 @@ function ld.parse(self, section, novld)
|
||||||
DDNS.value_parse(self, section, novld)
|
DDNS.value_parse(self, section, novld)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- log_lines -- ###############################################################
|
-- ddns_loglines -- ###########################################################
|
||||||
local ll = ns:option(Value, "log_lines")
|
local ll = ns:option(Value, "ddns_loglines")
|
||||||
ll.title = translate("Log length")
|
ll.title = translate("Log length")
|
||||||
ll.description = translate("Number of last lines stored in log files")
|
ll.description = translate("Number of last lines stored in log files")
|
||||||
ll.default = "250"
|
ll.default = "250"
|
||||||
|
|
|
@ -24,7 +24,7 @@ s = m:section( SimpleSection,
|
||||||
translate("Hints"),
|
translate("Hints"),
|
||||||
translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") )
|
translate("Below a list of configuration tips for your system to run Dynamic DNS updates without limitations") )
|
||||||
|
|
||||||
-- ddns_scripts needs to be updated for full functionality
|
-- ddns-scripts needs to be updated for full functionality
|
||||||
if not CTRL.service_ok() then
|
if not CTRL.service_ok() then
|
||||||
local so = s:option(DummyValue, "_update_needed")
|
local so = s:option(DummyValue, "_update_needed")
|
||||||
so.titleref = DISP.build_url("admin", "system", "packages")
|
so.titleref = DISP.build_url("admin", "system", "packages")
|
||||||
|
|
|
@ -33,10 +33,13 @@ m.description = CTRL.app_description()
|
||||||
|
|
||||||
m.on_after_commit = function(self)
|
m.on_after_commit = function(self)
|
||||||
if self.changed then -- changes ?
|
if self.changed then -- changes ?
|
||||||
|
local command = CTRL.luci_helper
|
||||||
if SYS.init.enabled("ddns") then -- ddns service enabled, restart all
|
if SYS.init.enabled("ddns") then -- ddns service enabled, restart all
|
||||||
os.execute("/etc/init.d/ddns restart")
|
command = command .. " -- restart"
|
||||||
|
os.execute(command)
|
||||||
else -- ddns service disabled, send SIGHUP to running
|
else -- ddns service disabled, send SIGHUP to running
|
||||||
os.execute("killall -1 dynamic_dns_updater.sh")
|
command = command .. " -- reload"
|
||||||
|
os.execute(command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -52,7 +55,7 @@ if show_hints or need_update or not_enabled then
|
||||||
|
|
||||||
s = m:section( SimpleSection, translate("Hints") )
|
s = m:section( SimpleSection, translate("Hints") )
|
||||||
|
|
||||||
-- ddns_scripts needs to be updated for full functionality
|
-- ddns-scripts needs to be updated for full functionality
|
||||||
if need_update then
|
if need_update then
|
||||||
local dv = s:option(DummyValue, "_update_needed")
|
local dv = s:option(DummyValue, "_update_needed")
|
||||||
dv.titleref = DISP.build_url("admin", "system", "packages")
|
dv.titleref = DISP.build_url("admin", "system", "packages")
|
||||||
|
@ -119,18 +122,21 @@ function dom.set_one(self, section)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function dom.set_two(self, section)
|
function dom.set_two(self, section)
|
||||||
local lookup = self.map:get(section, "lookup_host") or ""
|
local lookup_host = self.map:get(section, "lookup_host") or ""
|
||||||
if lookup == "" then return "" end
|
if lookup_host == "" then return "" end
|
||||||
local dnsserver = self.map:get(section, "dnsserver") or ""
|
local dnsserver = self.map:get(section, "dnsserver") or ""
|
||||||
local use_ipv6 = tonumber(self.map:get(section, "use_ipv6") or 0)
|
local use_ipv6 = tonumber(self.map:get(section, "use_ipv6") or 0)
|
||||||
local force_ipversion = tonumber(self.map:get(section, "force_ipversion") or 0)
|
local force_ipversion = tonumber(self.map:get(section, "force_ipversion") or 0)
|
||||||
local force_dnstcp = tonumber(self.map:get(section, "force_dnstcp") or 0)
|
local force_dnstcp = tonumber(self.map:get(section, "force_dnstcp") or 0)
|
||||||
local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh]]
|
local is_glue = tonumber(self.map:get(section, "is_glue") or 0)
|
||||||
if not NXFS.access(command, "rwx", "rx", "rx") then
|
local command = CTRL.luci_helper .. [[ -]]
|
||||||
NXFS.chmod(command, 755)
|
if (use_ipv6 == 1) then command = command .. [[6]] end
|
||||||
end
|
if (force_ipversion == 1) then command = command .. [[f]] end
|
||||||
command = command .. [[ get_registered_ip ]] .. lookup .. [[ ]] .. use_ipv6 ..
|
if (force_dnstcp == 1) then command = command .. [[t]] end
|
||||||
[[ ]] .. force_ipversion .. [[ ]] .. force_dnstcp .. [[ ]] .. dnsserver
|
if (is_glue == 1) then command = command .. [[g]] end
|
||||||
|
command = command .. [[l ]] .. lookup_host
|
||||||
|
if (#dnsserver > 0) then command = command .. [[ -d ]] .. dnsserver end
|
||||||
|
command = command .. [[ -- get_registered_ip]]
|
||||||
local ip = SYS.exec(command)
|
local ip = SYS.exec(command)
|
||||||
if ip == "" then ip = translate("no data") end
|
if ip == "" then ip = translate("no data") end
|
||||||
return ip
|
return ip
|
||||||
|
|
|
@ -57,7 +57,7 @@ end
|
||||||
function epoch2date(epoch, format)
|
function epoch2date(epoch, format)
|
||||||
if not format or #format < 2 then
|
if not format or #format < 2 then
|
||||||
local uci = UCI.cursor()
|
local uci = UCI.cursor()
|
||||||
format = uci:get("ddns", "global", "date_format") or "%F %R"
|
format = uci:get("ddns", "global", "ddns_dateformat") or "%F %R"
|
||||||
uci:unload("ddns")
|
uci:unload("ddns")
|
||||||
end
|
end
|
||||||
format = format:gsub("%%n", "<br />") -- replace newline
|
format = format:gsub("%%n", "<br />") -- replace newline
|
||||||
|
@ -67,18 +67,18 @@ end
|
||||||
|
|
||||||
-- read lastupdate from [section].update file
|
-- read lastupdate from [section].update file
|
||||||
function get_lastupd(section)
|
function get_lastupd(section)
|
||||||
local uci = UCI.cursor()
|
local uci = UCI.cursor()
|
||||||
local run_dir = uci:get("ddns", "global", "run_dir") or "/var/run/ddns"
|
local rdir = uci:get("ddns", "global", "ddns_rundir") or "/var/run/ddns"
|
||||||
local etime = tonumber(NXFS.readfile("%s/%s.update" % { run_dir, section } ) or 0 )
|
local etime = tonumber(NXFS.readfile("%s/%s.update" % { rdir, section } ) or 0 )
|
||||||
uci:unload("ddns")
|
uci:unload("ddns")
|
||||||
return etime
|
return etime
|
||||||
end
|
end
|
||||||
|
|
||||||
-- read PID from run file and verify if still running
|
-- read PID from run file and verify if still running
|
||||||
function get_pid(section)
|
function get_pid(section)
|
||||||
local uci = UCI.cursor()
|
local uci = UCI.cursor()
|
||||||
local run_dir = uci:get("ddns", "global", "run_dir") or "/var/run/ddns"
|
local rdir = uci:get("ddns", "global", "ddns_rundir") or "/var/run/ddns"
|
||||||
local pid = tonumber(NXFS.readfile("%s/%s.pid" % { run_dir, section } ) or 0 )
|
local pid = tonumber(NXFS.readfile("%s/%s.pid" % { rdir, section } ) or 0 )
|
||||||
if pid > 0 and not NX.kill(pid, 0) then
|
if pid > 0 and not NX.kill(pid, 0) then
|
||||||
pid = 0
|
pid = 0
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<script type="text/javascript">//<![CDATA[
|
<script type="text/javascript">//<![CDATA[
|
||||||
// event handler on changed date
|
// event handler on changed date
|
||||||
function onkeyup_date(value) {
|
function onkeyup_date(value) {
|
||||||
var obj = document.getElementById("cbid.ddns.global.date_format.help");
|
var obj = document.getElementById("cbid.ddns.global.ddns_dateformat.help");
|
||||||
if ( !obj ) { return; } // security check
|
if ( !obj ) { return; } // security check
|
||||||
|
|
||||||
if ( value == "" || value.length == 0 ) { value = "%F %R"; }
|
if ( value == "" || value.length == 0 ) { value = "%F %R"; }
|
||||||
|
|
|
@ -7,4 +7,4 @@ uci -q batch <<-EOF >/dev/null
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
rm -f /tmp/luci-indexcache
|
rm -f /tmp/luci-indexcache
|
||||||
exit 0
|
return 0
|
||||||
|
|
Loading…
Reference in a new issue