Merge pull request #256 from chris5560/master
luci-app-ddns: modified to support ddns-scripts 2.1.0-2
This commit is contained in:
commit
91532de617
10 changed files with 89 additions and 147 deletions
|
@ -1,3 +1,16 @@
|
|||
Version: 2.1.0-2
|
||||
Date: 2014-11-15
|
||||
ddns-scripts: 2.1.0-2 or greater needed
|
||||
|
||||
- moved /usr/lib/ddns/dynamic_dns_lucihelper.sh to ddns-scripts package
|
||||
- fixed error message when validating proxy
|
||||
- modified validating ip_script to allow the usage of parameters
|
||||
- using ipkg/postinst AND ipkg/postinst-pkg as long as LuCI Makefiles did not
|
||||
fullfil requirements of new OpenWrt default_postinst and default_postrm
|
||||
reported in Issue #255
|
||||
- cleanup whitespaces at line ends
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
Version: 2.1.0-1
|
||||
Date: 2014-11-09
|
||||
ddns-scripts: 2.1.0-1 or greater needed
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
#!/bin/sh
|
||||
[ -n "${IPKG_INSTROOT}" ] || {
|
||||
# luci updates are not in sync with ddns-script updates !!!
|
||||
# needed because luci update might delete helper script
|
||||
# copy dynamic_dns_helper.tmp.sh from ddns-scripts
|
||||
cp -f /usr/lib/ddns/dynamic_dns_lucihelper.tmp.sh /usr/lib/ddns/dynamic_dns_lucihelper.sh
|
||||
|
||||
( . /etc/uci-defaults/luci-ddns ) && rm -f /etc/uci-defaults/luci-ddns
|
||||
exit 0
|
||||
}
|
||||
|
|
10
applications/luci-ddns/ipkg/postinst-pkg
Normal file
10
applications/luci-ddns/ipkg/postinst-pkg
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/sh
|
||||
[ -n "${IPKG_INSTROOT}" ] || {
|
||||
# luci updates are not in sync with ddns-script updates !!!
|
||||
# needed because luci update might delete helper script
|
||||
# copy dynamic_dns_helper.tmp.sh from ddns-scripts
|
||||
cp -f /usr/lib/ddns/dynamic_dns_lucihelper.tmp.sh /usr/lib/ddns/dynamic_dns_lucihelper.sh
|
||||
|
||||
( . /etc/uci-defaults/luci-ddns ) && rm -f /etc/uci-defaults/luci-ddns
|
||||
exit 0
|
||||
}
|
|
@ -25,8 +25,8 @@ local SYS = require "luci.sys"
|
|||
local DDNS = require "luci.tools.ddns" -- ddns multiused functions
|
||||
local UTIL = require "luci.util"
|
||||
|
||||
local luci_ddns_version = "2.1.0-1" -- luci-app-ddns / openwrt Makefile compatible version
|
||||
local ddns_scripts_min = "2.1.0-1" -- minimum version of ddns-scripts required
|
||||
local luci_ddns_version = "2.1.0-2" -- luci-app-ddns / openwrt Makefile compatible version
|
||||
local ddns_scripts_min = "2.1.0-2" -- minimum version of ddns-scripts required
|
||||
|
||||
function index()
|
||||
-- above 'require "mod"' definitions are not recognized
|
||||
|
|
|
@ -112,7 +112,7 @@ local function _verify_ip_source()
|
|||
|
||||
local command = [[/usr/lib/ddns/dynamic_dns_lucihelper.sh get_local_ip ]] ..
|
||||
_ipv6 .. [[ ]] .. _source .. [[ ]] .. _network .. [[ ]] ..
|
||||
_url .. [[ ]] .. _interface .. [[ ]] .. _script.. [[ ]] .. _proxy
|
||||
_url .. [[ ]] .. _interface .. [[ ']] .. _script.. [[' ]] .. _proxy
|
||||
local ret = SYS.call(command)
|
||||
|
||||
if ret == 0 then
|
||||
|
@ -796,12 +796,16 @@ ips = ns:taboption("advanced", Value, "ip_script",
|
|||
translate("User defined script to read systems IP-Address") )
|
||||
ips:depends("ipv4_source", "script") -- IPv4
|
||||
ips:depends("ipv6_source", "script") -- or IPv6
|
||||
ips.rmempty = false
|
||||
ips.placeholder = "/path/to/script.sh"
|
||||
function ips.validate(self, value)
|
||||
local split
|
||||
if value then split = UTIL.split(value, " ") end
|
||||
|
||||
if (usev6:formvalue(section) == "0" and src4:formvalue(section) ~= "script")
|
||||
or (usev6:formvalue(section) == "1" and src6:formvalue(section) ~= "script") then
|
||||
return ""
|
||||
elseif not value or not FS.access(value, "x") then
|
||||
elseif not value or not (#value > 0) or not FS.access(split[1], "x") then
|
||||
return nil, err_tab_adv(self) ..
|
||||
translate("not found or not executable - Sample: '/path/to/script.sh'")
|
||||
else
|
||||
|
@ -1018,7 +1022,7 @@ if has_proxy or ( ( m:get(section, "proxy") or "" ) ~= "" ) then
|
|||
else return nil, err_tab_adv(self) .. translate("unspecific error")
|
||||
end
|
||||
else
|
||||
return nil, err .. translate("PROXY-Server not supported")
|
||||
return nil, err_tab_adv(self) .. translate("PROXY-Server not supported")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -141,10 +141,10 @@
|
|||
str += "\n\nluci-app-ddns:";
|
||||
str += "\n\t<%:Version%>:\t" + luci_version;
|
||||
str += "\n\t<%:Build%>:\t" + luci_build;
|
||||
str += "\n\nddns-scripts <%:installed%>:";
|
||||
str += "\n\t<%:Version%>:\t" + ddns_version;
|
||||
str += "\n\nddns-scripts <%:required%>:";
|
||||
str += "\n\t<%:Version%>:\t" + ddns_required + " <%:or greater%>";
|
||||
str += "\n\nddns-scripts <%:installed%>:";
|
||||
str += "\n\t<%:Version%>:\t" + ddns_version;
|
||||
str += "\n\n"
|
||||
alert(str);
|
||||
}
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
#!/bin/sh
|
||||
# /usr/lib/ddns/luci_dns_helper.sh
|
||||
#
|
||||
# Written in August 2014
|
||||
# by Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
# This script is used by luci-app-ddns
|
||||
# - getting registered IP
|
||||
# - check if possible to get local IP
|
||||
# - verifing given DNS- or Proxy-Server
|
||||
#
|
||||
# variables in small chars are read from /etc/config/ddns as parameter given here
|
||||
# variables in big chars are defined inside these scripts as gloval vars
|
||||
# variables in big chars beginning with "__" are local defined inside functions only
|
||||
# set -vx #script debugger
|
||||
|
||||
[ $# -lt 2 ] && exit 1
|
||||
|
||||
. /usr/lib/ddns/dynamic_dns_functions.sh # global vars are also defined here
|
||||
|
||||
# set -vx #script debugger
|
||||
|
||||
# preset some variables, wrong or not set in dynamic_dns_functions.sh
|
||||
SECTION_ID="lucihelper"
|
||||
LOGFILE="$LOGDIR/$SECTION_ID.log"
|
||||
VERBOSE_MODE=0 # no console logging
|
||||
# global variables normally set by reading DDNS UCI configuration
|
||||
use_syslog=0 # no syslog
|
||||
use_logfile=0 # by default no logfile, can be changed here
|
||||
|
||||
case "$1" in
|
||||
get_registered_ip)
|
||||
local IP
|
||||
domain=$2 # Hostname/Domain
|
||||
use_ipv6=${3:-"0"} # Use IPv6 - default IPv4
|
||||
force_ipversion=${4:-"0"} # Force IP Version - default 0 - No
|
||||
force_dnstcp=${5:-"0"} # Force TCP on DNS - default 0 - No
|
||||
dns_server=${6:-""} # DNS server - default No DNS
|
||||
write_log 7 "-----> get_registered_ip IP"
|
||||
get_registered_ip IP
|
||||
[ $? -ne 0 ] && IP=""
|
||||
echo -n "$IP" # suppress LF
|
||||
;;
|
||||
verify_dns)
|
||||
# $2 : dns-server to verify # no need for force_dnstcp because
|
||||
# verify with nc (netcat) uses tcp anyway
|
||||
use_ipv6=${3:-"0"} # Use IPv6 - default IPv4
|
||||
force_ipversion=${4:-"0"} # Force IP Version - default 0 - No
|
||||
write_log 7 "-----> verify_dns '$2'"
|
||||
verify_dns "$2"
|
||||
;;
|
||||
verify_proxy)
|
||||
# $2 : proxy string to verify
|
||||
use_ipv6=${3:-"0"} # Use IPv6 - default IPv4
|
||||
force_ipversion=${4:-"0"} # Force IP Version - default 0 - No
|
||||
write_log 7 "-----> verify_proxy '$2'"
|
||||
verify_proxy "$2"
|
||||
;;
|
||||
get_local_ip)
|
||||
local IP
|
||||
use_ipv6="$2" # Use IPv6
|
||||
ip_source="$3" # IP source
|
||||
ip_network="$4" # set if source = "network" otherwise "-"
|
||||
ip_url="$5" # set if source = "web" otherwise "-"
|
||||
ip_interface="$6" # set if source = "interface" itherwiase "-"
|
||||
ip_script="$7" # set if source = "script" otherwise "-"
|
||||
proxy="$8" # proxy if set
|
||||
force_ipversion="0" # not needed but must be set
|
||||
use_https="0" # not needed but must be set
|
||||
[ -n "$proxy" -a "$ip_source" = "web" ] && {
|
||||
# proxy defined, used for ip_source=web
|
||||
export HTTP_PROXY="http://$proxy"
|
||||
export HTTPS_PROXY="http://$proxy"
|
||||
export http_proxy="http://$proxy"
|
||||
export https_proxy="http://$proxy"
|
||||
}
|
||||
# don't need IP only the return code
|
||||
[ "$ip_source" = "web" -o "$ip_source" = "script" ] && {
|
||||
# we wait only 3 seconds for an
|
||||
# answer from "web" or "script"
|
||||
write_log 7 "-----> timeout 3 -- get_local_ip IP"
|
||||
timeout 3 -- get_local_ip IP
|
||||
} || {
|
||||
write_log 7 "-----> get_local_ip IP"
|
||||
get_local_ip IP
|
||||
}
|
||||
;;
|
||||
*)
|
||||
return 255
|
||||
;;
|
||||
esac
|
Loading…
Reference in a new issue