Browse Source

Merge pull request #1916 from chris5560/master

ddns-scripts: rollup to version 2.5.0-1
lilik-openwrt-22.03
Ted Hess 9 years ago
parent
commit
b261ef65cf
10 changed files with 1116 additions and 110 deletions
  1. +2
    -2
      net/ddns-scripts/Makefile
  2. +3
    -2
      net/ddns-scripts/files/ddns.config
  3. +41
    -39
      net/ddns-scripts/files/dynamic_dns_functions.sh
  4. +2
    -2
      net/ddns-scripts/files/dynamic_dns_lucihelper.sh
  5. +40
    -10
      net/ddns-scripts/files/dynamic_dns_updater.sh
  6. +18
    -11
      net/ddns-scripts/files/services
  7. +5
    -1
      net/ddns-scripts/files/services_ipv6
  8. +981
    -36
      net/ddns-scripts/files/tld_names.dat
  9. +18
    -3
      net/ddns-scripts/samples/ddns.config_sample
  10. +6
    -4
      net/ddns-scripts/samples/update_sample.sh

+ 2
- 2
net/ddns-scripts/Makefile View File

@ -9,10 +9,10 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=ddns-scripts
# Version == major.minor.patch
# increase on new functionality (minor) or patches (patch)
PKG_VERSION:=2.4.3
PKG_VERSION:=2.5.0
# Release == build
# increase on changes of services files or tld_names.dat
PKG_RELEASE:=2
PKG_RELEASE:=1
PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>


+ 3
- 2
net/ddns-scripts/files/ddns.config View File

@ -1,6 +1,5 @@
#
# Please read ddns.sample
# or http://wiki.openwrt.org/doc/uci/ddns
# Please read http://wiki.openwrt.org/doc/uci/ddns
#
config ddns "global"
option date_format "%F %R"
@ -12,6 +11,7 @@ config ddns "global"
config service "myddns_ipv4"
option service_name "dyndns.com"
option lookup_host "yourhost.example.com"
option domain "yourhost.example.com"
option username "your_username"
option password "your_password"
@ -21,6 +21,7 @@ config service "myddns_ipv4"
config service "myddns_ipv6"
option update_url "http://[USERNAME]:[PASSWORD]@your.provider.net/nic/update?hostname=[DOMAIN]&myip=[IP]"
option lookup_host "yourhost.example.com"
option domain "yourhost.example.com"
option username "your_username"
option password "your_password"


+ 41
- 39
net/ddns-scripts/files/dynamic_dns_functions.sh View File

@ -29,6 +29,7 @@
. /lib/functions/network.sh
# GLOBAL VARIABLES #
VERSION="2.5.0-1"
SECTION_ID="" # hold config's section name
VERBOSE_MODE=1 # default mode is log to console, but easily changed with parameter
@ -53,6 +54,9 @@ LOCAL_IP="" # holds the local IP read from the box
URL_USER="" # url encoded $username from config file
URL_PASS="" # url encoded $password from config file
URL_PENC="" # url encoded $param_enc from config file
SRV_ANSWER="" # Answer given by service on success
ERR_LAST=0 # used to save $? return code of program and function calls
ERR_UPDATE=0 # error counter on different local and registered ip
@ -299,40 +303,38 @@ urlencode() {
# file /usr/lib/ddns/services_ipv6 for IPv6
# $1 Name of Variable to store url to
# $2 Name of Variable to store script to
# $3 Name of Variable to store service answer to
get_service_data() {
local __LINE __FILE __NAME __URL __SERVICES __DATA
local __SCRIPT=""
local __OLD_IFS=$IFS
local __NEWLINE_IFS='
' # __NEWLINE_IFS
[ $# -ne 2 ] && write_log 12 "Error calling 'get_service_data()' - wrong number of parameters"
[ $# -ne 3 ] && write_log 12 "Error calling 'get_service_data()' - wrong number of parameters"
__FILE="/usr/lib/ddns/services" # IPv4
[ $use_ipv6 -ne 0 ] && __FILE="/usr/lib/ddns/services_ipv6" # IPv6
# remove any lines not containing data, and then make sure fields are enclosed in double quotes
__SERVICES=$(cat $__FILE | grep "^[\t ]*[^#]" | \
awk ' gsub("\x27", "\"") { if ($1~/^[^\"]*$/) $1="\""$1"\"" }; { if ( $NF~/^[^\"]*$/) $NF="\""$NF"\"" }; { print $0 }')
IFS=$__NEWLINE_IFS
for __LINE in $__SERVICES; do
# grep out proper parts of data and use echo to remove quotes
__NAME=$(echo $__LINE | grep -o "^[\t ]*\"[^\"]*\"" | xargs -r -n1 echo)
__DATA=$(echo $__LINE | grep -o "\"[^\"]*\"[\t ]*$" | xargs -r -n1 echo)
if [ "$__NAME" = "$service_name" ]; then
break # found so leave for loop
# workaround with variables; pipe create subshell with no give back of variable content
mkfifo pipe_$$
# only grep without # or whitespace at linestart | remove "
# grep -v -E "(^#|^[[:space:]]*$)" $__FILE | sed -e s/\"//g > pipe_$$ &
sed '/^#/d/^[ \t]*$/ds/\"//g' $__FILE > pipe_$$ &
while read __SERVICE __DATA __ANSWER; do
if [ "$__SERVICE" = "$service_name" ]; then
# check if URL or SCRIPT is given
__URL=$(echo "$__DATA" | grep "^http")
[ -z "$__URL" ] && __SCRIPT="/usr/lib/ddns/$__DATA"
eval "$1=\"$__URL\""
eval "$2=\"$__SCRIPT\""
eval "$3=\"$__ANSWER\""
rm pipe_$$
return 0
fi
done
IFS=$__OLD_IFS
done < pipe_$$
rm pipe_$$
# check if URL or SCRIPT is given
__URL=$(echo "$__DATA" | grep "^http")
[ -z "$__URL" ] && __SCRIPT="/usr/lib/ddns/$__DATA"
eval "$1=\"$__URL\""
eval "$2=\"$__SCRIPT\""
return 0
eval "$1=\"\"" # no service match clear variables
eval "$2=\"\""
eval "$3=\"\""
return 1
}
# Calculate seconds from interval and unit
@ -793,19 +795,19 @@ send_update() {
local __URL __ERR
# do replaces in URL
__URL=$(echo $update_url | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
-e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
__URL=$(echo $update_url | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
-e "s#\[PARAMENC\]#$URL_PENC#g" -e "s#\[PARAMOPT\]#$param_opt#g" \
-e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
do_transfer "$__URL" || return 1
write_log 7 "DDNS Provider answered:\n$(cat $DATFILE)"
return 0
# TODO analyze providers answer
# "good" or "nochg" = dyndns.com compatible API
# grep -i -E "good|nochg" $DATFILE >/dev/null 2>&1
# return $? # "0" if found
[ -z "$SRV_ANSWER" ] && return 0 # not set then ignore
grep -i -E "$SRV_ANSWER" $DATFILE >/dev/null 2>&1
return $? # "0" if found
fi
}
@ -943,13 +945,13 @@ get_registered_ip() {
fi
[ $force_dnstcp -eq 1 ] && __PROG="$__PROG -T" # force TCP
__RUNPROG="$__PROG $domain $dns_server >$DATFILE 2>$ERRFILE"
__RUNPROG="$__PROG $lookup_host $dns_server >$DATFILE 2>$ERRFILE"
__PROG="BIND host"
elif [ -x /usr/bin/nslookup ]; then # last use BusyBox nslookup
[ $force_ipversion -ne 0 -o $force_dnstcp -ne 0 ] && \
write_log 14 "Busybox nslookup - no support to 'force IP Version' or 'DNS over TCP'"
__RUNPROG="/usr/bin/nslookup $domain $dns_server >$DATFILE 2>$ERRFILE"
__RUNPROG="/usr/bin/nslookup $lookup_host $dns_server >$DATFILE 2>$ERRFILE"
__PROG="BusyBox nslookup"
else # there must be an error
write_log 12 "Error in 'get_registered_ip()' - no supported Name Server lookup software accessible"
@ -981,16 +983,16 @@ get_registered_ip() {
[ -n "$2" ] && return $__ERR # $2 is given -> no retry
[ $VERBOSE_MODE -gt 1 ] && {
# VERBOSE_MODE > 1 then NO retry
write_log 4 "Get registered/public IP for '$domain' failed - Verbose Mode: $VERBOSE_MODE - NO retry on error"
write_log 4 "Get registered/public IP for '$lookup_host' failed - Verbose Mode: $VERBOSE_MODE - NO retry on error"
return $__ERR
}
__CNT=$(( $__CNT + 1 )) # increment error counter
# if error count > retry_count leave here
[ $retry_count -gt 0 -a $__CNT -gt $retry_count ] && \
write_log 14 "Get registered/public IP for '$domain' failed after $retry_count retries"
write_log 14 "Get registered/public IP for '$lookup_host' failed after $retry_count retries"
write_log 4 "Get registered/public IP for '$domain' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
write_log 4 "Get registered/public IP for '$lookup_host' failed - retry $__CNT/$retry_count in $RETRY_SECONDS seconds"
sleep $RETRY_SECONDS &
PID_SLEEP=$!
wait $PID_SLEEP # enable trap-handler


+ 2
- 2
net/ddns-scripts/files/dynamic_dns_lucihelper.sh View File

@ -33,7 +33,7 @@ __RET=0
case "$1" in
get_registered_ip)
local IP
domain=$2 # Hostname/Domain
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
@ -99,4 +99,4 @@ esac
# remove out and err file
[ -f $DATFILE ] && rm -f $DATFILE
[ -f $ERRFILE ] && rm -f $ERRFILE
return $__RET
return $__RET

+ 40
- 10
net/ddns-scripts/files/dynamic_dns_updater.sh View File

@ -22,9 +22,14 @@
# variables in big chars beginning with "__" are local defined inside functions only
# set -vx #script debugger
. /usr/lib/ddns/dynamic_dns_functions.sh # global vars are also defined here
[ $# -lt 1 -o -n "${2//[0-3]/}" -o ${#2} -gt 1 ] && {
echo -e "\n ddns-scripts Version: $VERSION"
echo -e "\n USAGE:"
echo -e " $0 [SECTION] [VERBOSE_MODE]\n"
echo " $0 [OPTION]"
echo " [OPTION] '-V' or '--version' display version and exit"
echo -e "\n $0 [SECTION] [VERBOSE_MODE]\n"
echo " [SECTION] - service section as defined in /etc/config/ddns"
echo " [VERBOSE_MODE] - '0' NO output to console"
echo " '1' output to console"
@ -36,7 +41,10 @@
exit 1
}
. /usr/lib/ddns/dynamic_dns_functions.sh # global vars are also defined here
[ "$1" = "-V" -o "$1" = "--version" ] && {
echo -e "ddns-scripts $VERSION\n"
exit 0
}
SECTION_ID="$1"
VERBOSE_MODE=${2:-1} # default mode is log to console
@ -77,9 +85,12 @@ trap "trap_handler 15" 15 # SIGTERM Termination
# update_url URL to use to update your "custom" DDNS service
# update_script SCRIPT to use to update your "custom" DDNS service
#
# domain Your DNS name / replace [DOMAIN] in update_url
# username Username of your DDNS service account / replace [USERNAME] in update_url
# password Password of your DDNS service account / replace [PASSWORD] in update_url
# lookup_host FQDN of ONE of your at DDNS service defined host / required to validate if IP update happen/necessary
# domain Nomally your DDNS hostname / replace [DOMAIN] in update_url
# username Username of your DDNS service account / urlenceded and replace [USERNAME] in update_url
# password Password of your DDNS service account / urlencoded and replace [PASSWORD] in update_url
# param_enc Optional parameter for (later) usage / urlencoded and replace [PARAMENC] in update_url
# param_opt Optional parameter for (later) usage / replace [PARAMOPT] in update_url
#
# use_https use HTTPS to update DDNS service
# cacert file or directory where HTTPS can find certificates to verify server; 'IGNORE' ignore check of server certificate
@ -140,14 +151,16 @@ ERR_LAST=$? # save return code - equal 0 if SECTION_ID found
[ -f $LOGFILE ] && rm -f $LOGFILE # clear logfile before first entry
write_log 7 "************ ************** ************** **************"
write_log 5 "PID '$$' started at $(eval $DATE_PROG)"
write_log 7 "ddns version : $VERSION"
write_log 7 "uci configuration:\n$(uci -q show ddns | grep '=service' | sort)"
write_log 14 "Service section '$SECTION_ID' not defined"
}
write_log 7 "************ ************** ************** **************"
write_log 5 "PID '$$' started at $(eval $DATE_PROG)"
write_log 7 "ddns version : $VERSION"
write_log 7 "uci configuration:\n$(uci -q show ddns.$SECTION_ID | sort)"
write_log 7 "ddns version : $(opkg list-installed ddns-scripts | cut -d ' ' -f 3)"
# write_log 7 "ddns version : $(opkg list-installed ddns-scripts | cut -d ' ' -f 3)"
case $VERBOSE_MODE in
0) write_log 7 "verbose mode : 0 - run normal, NO console output";;
1) write_log 7 "verbose mode : 1 - run normal, console mode";;
@ -162,24 +175,41 @@ esac
# determine what update url we're using if a service_name is supplied
# otherwise update_url is set inside configuration (custom update url)
# or update_script is set inside configuration (custom update script)
[ -n "$service_name" ] && get_service_data update_url update_script
[ -n "$service_name" ] && get_service_data update_url update_script SRV_ANSWER
[ -z "$update_url" -a -z "$update_script" ] && write_log 14 "No update_url found/defined or no update_script found/defined!"
[ -n "$update_script" -a ! -f "$update_script" ] && write_log 14 "Custom update_script not found!"
# without domain and possibly username and password we can do nothing for you
[ -z "$domain" ] && write_log 14 "Service section not configured correctly! Missing 'domain'"
# temporary needed to convert existing uci settings
[ -z "$lookup_host" ] && {
uci -q set ddns.$SECTION_ID.lookup_host="$domain"
uci -q commit ddns
lookup_host="$domain"
}
# later versions only check if configured correctly
# without lookup host and possibly other required options we can do nothing for you
[ -z "$lookup_host" ] && write_log 14 "Service section not configured correctly! Missing 'lookup_host'"
[ -n "$update_url" ] && {
# only check if update_url is given, update_scripts have to check themselves
[ -z "$domain" ] && $(echo "$update_url" | grep "\[DOMAIN\]" >/dev/null 2>&1) && \
write_log 14 "Service section not configured correctly! Missing 'domain'"
[ -z "$username" ] && $(echo "$update_url" | grep "\[USERNAME\]" >/dev/null 2>&1) && \
write_log 14 "Service section not configured correctly! Missing 'username'"
[ -z "$password" ] && $(echo "$update_url" | grep "\[PASSWORD\]" >/dev/null 2>&1) && \
write_log 14 "Service section not configured correctly! Missing 'password'"
[ -z "$param_enc" ] && $(echo "$update_url" | grep "\[PARAMENC\]" >/dev/null 2>&1) && \
write_log 14 "Service section not configured correctly! Missing 'param_enc'"
[ -z "$param_opt" ] && $(echo "$update_url" | grep "\[PARAMOPT\]" >/dev/null 2>&1) && \
write_log 14 "Service section not configured correctly! Missing 'param_opt'"
}
# url encode username (might be email or something like this)
# and password (might have special chars for security reason)
# and optional parameter "param_enc"
[ -n "$username" ] && urlencode URL_USER "$username"
[ -n "$password" ] && urlencode URL_PASS "$password"
[ -n "$param_enc" ] && urlencode URL_PENC "$param_enc"
# verify ip_source 'script' if script is configured and executable
if [ "$ip_source" = "script" ]; then
@ -289,7 +319,7 @@ while : ; do
&& write_log 6 "Update successful - IP '$LOCAL_IP' send" \
|| write_log 6 "Forced update successful - IP: '$LOCAL_IP' send"
else
write_log 3 "Can not update IP at DDNS Provider"
write_log 3 "IP update not accepted by DDNS Provider"
fi
fi


+ 18
- 11
net/ddns-scripts/files/services View File

@ -46,18 +46,18 @@
"dnsexit.com" "http://www.dnsexit.com/RemoteUpdate.sv?login=[USERNAME]&password=[PASSWORD]&host=[DOMAIN]&myip=[IP]"
# OVH
"ovh.com" "http://[USERNAME]:[PASSWORD]@www.ovh.com/nic/update?system=dyndns&hostname=[DOMAIN]&myip=[IP]"
"ovh.com" "http://[USERNAME]:[PASSWORD]@www.ovh.com/nic/update?system=dyndns&hostname=[DOMAIN]&myip=[IP]"
# dns-o-matic is a free service by opendns.com for updating multiple hosts and
# dynamic dns services in one api call. To update all your configured services
# at once, use "all.dnsomatic.com as the hostname.
"dnsomatic.com" "http://[USERNAME]:[PASSWORD]@updates.dnsomatic.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
"dnsomatic.com" "http://[USERNAME]:[PASSWORD]@updates.dnsomatic.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
# 3322.org
"3322.org" "http://[USERNAME]:[PASSWORD]@members.3322.org/dyndns/update?system=dyndns&hostname=[DOMAIN]&myip=[IP]"
"3322.org" "http://[USERNAME]:[PASSWORD]@members.3322.org/dyndns/update?system=dyndns&hostname=[DOMAIN]&myip=[IP]"
# namecheap.com
"namecheap.com" "http://dynamicdns.park-your-domain.com/update?host=[USERNAME]&domain=[DOMAIN]&password=[PASSWORD]&ip=[IP]"
"namecheap.com" "http://dynamicdns.park-your-domain.com/update?host=[USERNAME]&domain=[DOMAIN]&password=[PASSWORD]&ip=[IP]"
# easydns.com dynamic DNS
"easydns.com" "http://[USERNAME]:[PASSWORD]@api.cp.easydns.com/dyn/tomato.php?hostname=[DOMAIN]&myip=[IP]"
@ -69,28 +69,35 @@
"mythic-beasts.com" "http://dnsapi4.mythic-beasts.com/?domain=[USERNAME]&password=[PASSWORD]&command=REPLACE%20[DOMAIN]%2060%20A%20DYNAMIC_IP"
# Securepoint Dynamic-DNS-Service (http://www.spdns.de)
"spdns.de" "http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
"spdns.de" "http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]" "good|nochg"
# duiadns.net - free dynamic DNS
"duiadns.net" "http://ipv4.duia.ro/dynamic.duia?host=[DOMAIN]&password=[PASSWORD]&ip4=[IP]"
"duiadns.net" "http://ipv4.duia.ro/dynamic.duia?host=[DOMAIN]&password=[PASSWORD]&ip4=[IP]"
# Two-DNS - Simply. Connected. Everywhere.
"twodns.de" "http://[USERNAME]:[PASSWORD]@update.twodns.de/update?hostname=[DOMAIN]&ip=[IP]"
"twodns.de" "http://[USERNAME]:[PASSWORD]@update.twodns.de/update?hostname=[DOMAIN]&ip=[IP]"
# MyDNS.JP
"mydns.jp" "http://www.mydns.jp/directip.html?MID=[USERNAME]&PWD=[PASSWORD]&IPV4ADDR=[IP]"
# LoopiaDNS
"loopia.se" "http://[USERNAME]:[PASSWORD]@dns.loopia.se/XDynDNSServer/XDynDNS.php?system=custom&hostname=[DOMAIN]&myip=[IP]"
"loopia.se" "http://[USERNAME]:[PASSWORD]@dns.loopia.se/XDynDNSServer/XDynDNS.php?system=custom&hostname=[DOMAIN]&myip=[IP]"
# SelfHost.de
"selfhost.de" "http://carol.selfhost.de/update?username=[USERNAME]&password=[PASSWORD]&myip=[IP]&hostname=1"
"selfhost.de" "http://carol.selfhost.de/update?username=[USERNAME]&password=[PASSWORD]&myip=[IP]&hostname=1" "good|nochg"
# no-ip.pl nothing to do with no-ip.com (domain registered to www.domeny.tv) (IP autodetected by provider)
"no-ip.pl" "http://[USERNAME]:[PASSWORD]@update.no-ip.pl/?hostname=[DOMAIN]"
# domains.google.com non free service - require HTTPS communication
"domains.google.com" "https://[USERNAME]:[PASSWORD]@domains.google.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
"domains.google.com" "http://[USERNAME]:[PASSWORD]@domains.google.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
# Schokokeks Hosting, schokokeks.org
"schokokeks.org" "http://[USERNAME]:[PASSWORD]@dyndns.schokokeks.org/nic/update?myip=[IP]"
"schokokeks.org" "http://[USERNAME]:[PASSWORD]@dyndns.schokokeks.org/nic/update?myip=[IP]"
# STRATO AG
"strato.de" "http://[USERNAME]:[PASSWORD]@dyndns.strato.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
# Variomedia AG
"variomedia.de" "http://[USERNAME]:[PASSWORD]@dyndns.variomedia.de/nic/update?hostname=[DOMAIN]&myip=[IP]"

+ 5
- 1
net/ddns-scripts/files/services_ipv6 View File

@ -25,7 +25,7 @@
# 66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
# IPv6 @ Securepoint Dynamic-DNS-Service
"spdns.de" "http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
"spdns.de" "http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]" "good|nochg"
# IPv6 @ Hurricane Electric Dynamic DNS
"he.net" "http://[DOMAIN]:[PASSWORD]@dyn.dns.he.net/nic/update?hostname=[DOMAIN]&myip=[IP]"
@ -41,3 +41,7 @@
# IPv6 @ LoopiaDNS
"loopia.se" "http://[USERNAME]:[PASSWORD]@dns.loopia.se/XDynDNSServer/XDynDNS.php?system=custom&hostname=[DOMAIN]&myip=[IP]"
# Variomedia AG
"variomedia.de" "http://[USERNAME]:[PASSWORD]@dyndns.variomedia.de/nic/update?hostname=[DOMAIN]&myip=[IP]"

+ 981
- 36
net/ddns-scripts/files/tld_names.dat
File diff suppressed because it is too large
View File


+ 18
- 3
net/ddns-scripts/samples/ddns.config_sample View File

@ -115,9 +115,13 @@ config service "myddns"
# option update_script ""
###########
# You must specify your domain/host name, your username and your password
# as you get from you DDNS provider. Keep an eye on providers help pages.
# Keep an eye on providers help pages.
#
# FQDN of ONE of your defined host at DDNS provider
# REQUIRED to verify what the current IP at DNS using nslookup/host command
# default: none
option lookup_host ""
# Your DNS name / replace [DOMAIN] in update_url
# default: none
option domain ""
@ -126,10 +130,21 @@ config service "myddns"
# default: none
option username ""
# Password of your DDNS service account / replace [PASSWORD] in update_url
# Password of your DDNS service account / replace [PASSWORD] in update url
# default: none
option password ""
###########
# Optional parameters for use inside update_url
#
# parameter that will be urlencoded before replacement of [PARAMENC] inside update url
# default: none
option param_enc ""
# parameter that repace [PARAMOPT] inside update url
# default: none
option param_opt ""
###########
# use HTTPS for secure communication with you DDNS provider
# personally found some providers having problems when not sending


+ 6
- 4
net/ddns-scripts/samples/update_sample.sh View File

@ -18,13 +18,15 @@
#
# tested with spdns.de
local __URL="http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
# inside url we need username and password
# inside url we need domain, username and password
[ -z "$domain" ] && write_log 14 "Service section not configured correctly! Missing 'domain'"
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
# do replaces in URL
__URL=$(echo $__URL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
-e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
__URL=$(echo $__URL | | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
-e "s#\[PARAMENC\]#$URL_PENC#g" -e "s#\[PARAMOPT\]#$param_opt#g" \
-e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__IP#g")
[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
do_transfer "$__URL" || return 1
@ -34,6 +36,6 @@ write_log 7 "DDNS Provider answered:\n$(cat $DATFILE)"
# analyse provider answers
# "good [IP_ADR]" = successful
# "nochg [IP_ADR]" = no change but OK
grep -E "good|nochg" $DATFILE >/dev/null 2>&1
grep -i -E "good|nochg" $DATFILE >/dev/null 2>&1
return $? # "0" if "good" or "nochg" found

Loading…
Cancel
Save