ddns-scripts: update to 2.7.6-1

- tld_names.dat.gz
  - rename to public_suffix_list.dat.gz
  - (re)created during build
  - new location /usr/share
- move services files to /etc/ddns
- new services
  - CloudFlare.com-v4 using API-Version 4 without using public_suffix_list.dat
  - GoDaddy.com
  - both depending on cURL package
  - both with modified syntax for option domain ( NEW: [host[.subdom]@]domain.tld )
- new service
  - Now-DNS.com formerly Now-IP.com
- service afraid.org now supports key-auth and basic-auth
- new command line options for dynamic_dns_updater.sh and dynamic_dns_updater.sh
- adapted ddns.init and ddns.hotplug to new command line options
- renaming config options inside section global

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
This commit is contained in:
Christian Schoenebeck
2016-12-04 16:47:09 +01:00
parent 4a07953154
commit 1c20dcb71a
16 changed files with 954 additions and 12445 deletions
+108 -39
View File
@@ -1,5 +1,5 @@
#!/bin/sh
# /usr/lib/ddns/luci_dns_helper.sh
# /usr/lib/ddns/dynamic_dns_lucihelper.sh
#
#.Distributed under the terms of the GNU General Public License (GPL) version 2.0
#.2014-2016 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
@@ -10,63 +10,120 @@
# 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
# preset some variables, wrong or not set in dynamic_dns_functions.sh
usage() {
cat << EOF
Usage:
$MYPROG [options] -- command
Commands:
get_local_ip using given INTERFACE or NETWORK or SCRIPT or URL
get_registered_ip for given FQDN
verify_dns given DNS-SERVER
verify_proxy given PROXY
start start given SECTION
reload force running ddns processes to reload changed configuration
restart restart all ddns processes
Parameters:
-6 => use_ipv6=1 (default 0)
-d DNS-SERVER => dns_server=SERVER[:PORT]
-f => force_ipversion=1 (default 0)
-g => is_glue=1 (default 0)
-i INTERFACE => ip_interface=INTERFACE; ip_source="interface"
-l FQDN => lookup_host=FQDN
-n NETWORK => ip_network=NETWORK; ip_source="network"
-p PROXY => proxy=[USER:PASS@]PROXY:PORT
-s SCRIPT => ip_script=SCRIPT; ip_source="script"
-t => force_dnstcp=1 (default 0)
-u URL => ip_url=URL; ip_source="web"
-S SECTION SECTION to start
-h => show this help and exit
-L => use_logfile=1 (default 0)
-v LEVEL => VERBOSE=LEVEL (default 0)
-V => show version and exit
EOF
}
usage_err() {
printf %s\\n "$MYPROG: $@" >&2
usage >&2
exit 255
}
# preset some variables, wrong or not set in ddns-functions.sh
SECTION_ID="lucihelper"
LOGFILE="$LOGDIR/$SECTION_ID.log"
DATFILE="$RUNDIR/$SECTION_ID.$$.dat" # save stdout data of WGet and other extern programs called
ERRFILE="$RUNDIR/$SECTION_ID.$$.err" # save stderr output of WGet and other extern programs called
VERBOSE_MODE=0 # no console logging
LOGFILE="$ddns_logdir/$SECTION_ID.log"
DATFILE="$ddns_rundir/$SECTION_ID.$$.dat" # save stdout data of WGet and other extern programs called
ERRFILE="$ddns_rundir/$SECTION_ID.$$.err" # save stderr output of WGet and other extern programs called
DDNSPRG="/usr/lib/ddns/dynamic_dns_updater.sh"
VERBOSE=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
use_logfile=0 # no logfile
use_ipv6=0 # Use IPv6 - default IPv4
force_ipversion=0 # Force IP Version - default 0 - No
force_dnstcp=0 # Force TCP on DNS - default 0 - No
is_glue=0 # Is glue record - default 0 - No
use_https=0 # not needed but must be set
while getopts ":6d:fghi:l:n:p:s:S:tu:Lv:V" OPT; do
case "$OPT" in
6) use_ipv6=1;;
d) dns_server="$OPTARG";;
f) force_ipversion=1;;
g) is_glue=1;;
i) ip_interface="$OPTARG"; ip_source="interface";;
l) lookup_host="$OPTARG";;
n) ip_network="$OPTARG"; ip_source="network";;
p) proxy="$OPTARG";;
s) ip_script="$OPTARG"; ip_source="script";;
t) force_dnstcp=1;;
u) ip_url="$OPTARG"; ip_source="web";;
h) usage; exit 255;;
L) use_logfile=1;;
v) VERBOSE=$OPTARG;;
S) SECTION=$OPTARG;;
V) printf %s\\n "ddns-scripts $VERSION"; exit 255;;
:) usage_err "option -$OPTARG missing argument";;
\?) usage_err "invalid option -$OPTARG";;
*) usage_err "unhandled option -$OPT $OPTARG";;
esac
done
shift $((OPTIND - 1 )) # OPTIND is 1 based
[ $# -eq 0 ] && usage_err "missing command"
__RET=0
case "$1" in
get_registered_ip)
lookup_host=$2 # FQDN of host registered at DDNS
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
is_glue=${6:-"0"} # Is glue record - default 0 - No
dns_server=${7:-""} # DNS server - default No DNS
[ -z "$lookup_host" ] && usage_err "command 'get_registered_ip': 'lookup_host' not set"
write_log 7 "-----> get_registered_ip IP"
IP=""
get_registered_ip IP
__RET=$?
[ $__RET -ne 0 ] && IP=""
echo -n "$IP" # suppress LF
printf "%s" "$IP"
;;
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"
[ -z "$dns_server" ] && usage_err "command 'verify_dns': 'dns_server' not set"
write_log 7 "-----> verify_dns '$dns_server'"
verify_dns "$dns_server"
__RET=$?
;;
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"
[ -z "$proxy" ] && usage_err "command 'verify_proxy': 'proxy' not set"
write_log 7 "-----> verify_proxy '$proxy'"
verify_proxy "$proxy"
__RET=$?
;;
get_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
[ -z "$ip_source" ] && usage_err "command 'get_local_ip': 'ip_source' not set"
[ -n "$proxy" -a "$ip_source" = "web" ] && {
# proxy defined, used for ip_source=web
export HTTP_PROXY="http://$proxy"
@@ -76,17 +133,29 @@ case "$1" in
}
# don't need IP only the return code
IP=""
[ "$ip_source" = "web" -o "$ip_source" = "script" ] && {
if [ "$ip_source" = "web" -o "$ip_source" = "script" ]; then
# 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
} || {
else
write_log 7 "-----> get_local_ip IP"
get_local_ip IP
}
fi
__RET=$?
;;
start)
[ -z "$SECTION" ] && usage_err "command 'start': 'SECTION' not set"
$DDNSPRG -v $VERBOSE -S $SECTION -- start
;;
reload)
$DDNSPRG -- reload
;;
restart)
$DDNSPRG -- stop
sleep 1
$DDNSPRG -- start
;;
*)
__RET=255
;;