mirror of
https://github.com/openwrt/packages.git
synced 2025-12-19 00:51:19 +00:00
ddns-scripts: Update to version 2.2.0-1
modified source directory structure - files for production files - samples for sample files (not installed in final build) modified Makefile - separate options for additional provider scripts - remove comments and empty lines from final build add IPv4 100.64/10 (RFC 6598) and 169.254/16 (RFC 5735) to the range of default blocked IP's. new option "bind_network" to force GNU Wget or cURL to use specific network/interface for communication new "domains.google.com" as IPv4 DDNS provider #822 Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,100 +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
|
||||
|
||||
# preset some variables, wrong or not set in dynamic_dns_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
|
||||
# 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
|
||||
|
||||
__RET=0
|
||||
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
|
||||
__RET=$?
|
||||
[ $__RET -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"
|
||||
__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"
|
||||
__RET=$?
|
||||
;;
|
||||
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
|
||||
}
|
||||
__RET=$?
|
||||
;;
|
||||
*)
|
||||
__RET=255
|
||||
;;
|
||||
esac
|
||||
|
||||
# remove out and err file
|
||||
[ -f $DATFILE ] && rm -f $DATFILE
|
||||
[ -f $ERRFILE ] && rm -f $ERRFILE
|
||||
return $__RET
|
||||
@@ -1,334 +0,0 @@
|
||||
#!/bin/sh
|
||||
# /usr/lib/ddns/dynamic_dns_updater.sh
|
||||
#
|
||||
# Original written by Eric Paul Bishop, January 2008
|
||||
# Distributed under the terms of the GNU General Public License (GPL) version 2.0
|
||||
# (Loosely) based on the script on the one posted by exobyte in the forums here:
|
||||
# http://forum.openwrt.org/viewtopic.php?id=14040
|
||||
#
|
||||
# extended and partial rewritten in August 2014
|
||||
# by Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
# to support:
|
||||
# - IPv6 DDNS services
|
||||
# - DNS Server to retrieve registered IP including TCP transport (Ticket 7820)
|
||||
# - Proxy Server to send out updates
|
||||
# - force_interval=0 to run once (Luci Ticket 538)
|
||||
# - the usage of BIND's host command instead of BusyBox's nslookup if installed
|
||||
# - extended Verbose Mode and log file support for better error detection
|
||||
# - wait for interface to fully come up, before the first update is done
|
||||
#
|
||||
# variables in small chars are read from /etc/config/ddns
|
||||
# variables in big chars are defined inside these scripts as global vars
|
||||
# variables in big chars beginning with "__" are local defined inside functions only
|
||||
# set -vx #script debugger
|
||||
|
||||
[ $# -lt 1 -o -n "${2//[0-3]/}" -o ${#2} -gt 1 ] && {
|
||||
echo -e "\n USAGE:"
|
||||
echo -e " $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"
|
||||
echo " '2' output to console AND logfile"
|
||||
echo " + run once WITHOUT retry on error"
|
||||
echo " '3' output to console AND logfile"
|
||||
echo " + run once WITHOUT retry on error"
|
||||
echo -e " + NOT sending update to DDNS service\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
. /usr/lib/ddns/dynamic_dns_functions.sh # global vars are also defined here
|
||||
|
||||
SECTION_ID="$1"
|
||||
VERBOSE_MODE=${2:-1} # default mode is log to console
|
||||
|
||||
# set file names
|
||||
PIDFILE="$RUNDIR/$SECTION_ID.pid" # Process ID file
|
||||
UPDFILE="$RUNDIR/$SECTION_ID.update" # last update successful send (system uptime)
|
||||
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
|
||||
LOGFILE="$LOGDIR/$SECTION_ID.log" # log file
|
||||
|
||||
# VERBOSE_MODE > 1 delete logfile if exist to create an empty one
|
||||
# only with this data of this run for easier diagnostic
|
||||
# new one created by write_log function
|
||||
[ $VERBOSE_MODE -gt 1 -a -f $LOGFILE ] && rm -f $LOGFILE
|
||||
|
||||
# TRAP handler
|
||||
trap "trap_handler 0 \$?" 0 # handle script exit with exit status
|
||||
trap "trap_handler 1" 1 # SIGHUP Hangup / reload config
|
||||
trap "trap_handler 2" 2 # SIGINT Terminal interrupt
|
||||
trap "trap_handler 3" 3 # SIGQUIT Terminal quit
|
||||
# trap "trap_handler 9" 9 # SIGKILL no chance to trap
|
||||
trap "trap_handler 15" 15 # SIGTERM Termination
|
||||
|
||||
################################################################################
|
||||
# Leave this comment here, to clearly document variable names that are expected/possible
|
||||
# Use load_all_config_options to load config options, which is a much more flexible solution.
|
||||
#
|
||||
# config_load "ddns"
|
||||
# config_get <variable> $SECTION_ID <option>
|
||||
#
|
||||
# defined options (also used as variable):
|
||||
#
|
||||
# enable self-explanatory
|
||||
# interface network interface used by hotplug.d i.e. 'wan' or 'wan6'
|
||||
#
|
||||
# service_name Which DDNS service do you use or "custom"
|
||||
# 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
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# use_syslog log activity to syslog
|
||||
#
|
||||
# ip_source source to detect current local IP ('network' or 'web' or 'script' or 'interface')
|
||||
# ip_network local defined network to read IP from i.e. 'wan' or 'wan6'
|
||||
# ip_url URL to read local address from i.e. http://checkip.dyndns.com/ or http://checkipv6.dyndns.com/
|
||||
# ip_script full path and name of your script to detect local IP
|
||||
# ip_interface physical interface to use for detecting
|
||||
#
|
||||
# check_interval check for changes every !!! checks below 10 minutes make no sense because the Internet
|
||||
# check_unit 'days' 'hours' 'minutes' !!! needs about 5-10 minutes to sync an IP-change for an DNS entry
|
||||
#
|
||||
# force_interval force to send an update to your service if no change was detected
|
||||
# force_unit 'days' 'hours' 'minutes' !!! force_interval="0" runs this script once for use i.e. with cron
|
||||
#
|
||||
# retry_interval if error was detected retry in
|
||||
# retry_unit 'days' 'hours' 'minutes' 'seconds'
|
||||
# retry_count number of retries before scripts stops
|
||||
#
|
||||
# use_ipv6 detecting/sending IPv6 address
|
||||
# force_ipversion force usage of IPv4 or IPv6 for the whole detection and update communication
|
||||
# dns_server using a non default dns server to get Registered IP from Internet
|
||||
# force_dnstcp force communication with DNS server via TCP instead of default UDP
|
||||
# proxy using a proxy for communication !!! ALSO used to detect local IP via web => return proxy's IP !!!
|
||||
# use_logfile self-explanatory "/var/log/ddns/$SECTION_ID.log"
|
||||
#
|
||||
# some functionality needs
|
||||
# - GNU Wget or cURL installed for sending updates to DDNS service
|
||||
# - BIND host installed to detect Registered IP
|
||||
#
|
||||
################################################################################
|
||||
|
||||
load_all_config_options "ddns" "$SECTION_ID"
|
||||
ERR_LAST=$? # save return code - equal 0 if SECTION_ID found
|
||||
|
||||
# set defaults if not defined
|
||||
[ -z "$enabled" ] && enabled=0
|
||||
[ -z "$retry_count" ] && retry_count=5
|
||||
[ -z "$use_syslog" ] && use_syslog=2 # syslog "Notice"
|
||||
[ -z "$use_https" ] && use_https=0 # not use https
|
||||
[ -z "$use_logfile" ] && use_logfile=1 # use logfile by default
|
||||
[ -z "$use_ipv6" ] && use_ipv6=0 # use IPv4 by default
|
||||
[ -z "$force_ipversion" ] && force_ipversion=0 # default let system decide
|
||||
[ -z "$force_dnstcp" ] && force_dnstcp=0 # default UDP
|
||||
[ -z "$ip_source" ] && ip_source="network"
|
||||
[ "$ip_source" = "network" -a -z "$ip_network" -a $use_ipv6 -eq 0 ] && ip_network="wan" # IPv4: default wan
|
||||
[ "$ip_source" = "network" -a -z "$ip_network" -a $use_ipv6 -eq 1 ] && ip_network="wan6" # IPv6: default wan6
|
||||
[ "$ip_source" = "web" -a -z "$ip_url" -a $use_ipv6 -eq 0 ] && ip_url="http://checkip.dyndns.com"
|
||||
[ "$ip_source" = "web" -a -z "$ip_url" -a $use_ipv6 -eq 1 ] && ip_url="http://checkipv6.dyndns.com"
|
||||
[ "$ip_source" = "interface" -a -z "$ip_interface" ] && ip_interface="eth1"
|
||||
|
||||
# SECTION_ID does not exists
|
||||
[ $ERR_LAST -ne 0 ] && {
|
||||
[ $VERBOSE_MODE -le 1 ] && VERBOSE_MODE=2 # force console out and logfile output
|
||||
[ -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 "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 "uci configuration:\n$(uci -q show ddns.$SECTION_ID | sort)"
|
||||
write_log 7 "ddns version : $(opkg list-installed ddns-scripts | awk '{print $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";;
|
||||
2) write_log 7 "verbose mode : 2 - run once, NO retry on error";;
|
||||
3) write_log 7 "verbose mode : 3 - run once, NO retry on error, NOT sending update";;
|
||||
*) write_log 14 "error detecting VERBOSE_MODE '$VERBOSE_MODE'";;
|
||||
esac
|
||||
|
||||
# check enabled state otherwise we don't need to continue
|
||||
[ $enabled -eq 0 ] && write_log 14 "Service section disabled!"
|
||||
|
||||
# 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
|
||||
[ -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'"
|
||||
[ -n "$update_url" ] && {
|
||||
# only check if update_url is given, update_scripts have to check themselves
|
||||
[ -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'"
|
||||
}
|
||||
|
||||
# url encode username (might be email or something like this)
|
||||
# and password (might have special chars for security reason)
|
||||
[ -n "$username" ] && urlencode URL_USER "$username"
|
||||
[ -n "$password" ] && urlencode URL_PASS "$password"
|
||||
|
||||
# verify ip_source 'script' if script is configured and executable
|
||||
if [ "$ip_source" = "script" ]; then
|
||||
set -- $ip_script #handling script with parameters, we need a trick
|
||||
[ -z "$1" ] && write_log 14 "No script defined to detect local IP!"
|
||||
[ -x "$1" ] || write_log 14 "Script to detect local IP not executable!"
|
||||
fi
|
||||
|
||||
# compute update interval in seconds
|
||||
get_seconds CHECK_SECONDS ${check_interval:-10} ${check_unit:-"minutes"} # default 10 min
|
||||
get_seconds FORCE_SECONDS ${force_interval:-72} ${force_unit:-"hours"} # default 3 days
|
||||
get_seconds RETRY_SECONDS ${retry_interval:-60} ${retry_unit:-"seconds"} # default 60 sec
|
||||
[ $CHECK_SECONDS -lt 300 ] && CHECK_SECONDS=300 # minimum 5 minutes
|
||||
[ $FORCE_SECONDS -gt 0 -a $FORCE_SECONDS -lt $CHECK_SECONDS ] && FORCE_SECONDS=$CHECK_SECONDS # FORCE_SECONDS >= CHECK_SECONDS or 0
|
||||
write_log 7 "check interval: $CHECK_SECONDS seconds"
|
||||
write_log 7 "force interval: $FORCE_SECONDS seconds"
|
||||
write_log 7 "retry interval: $RETRY_SECONDS seconds"
|
||||
write_log 7 "retry counter : $retry_count times"
|
||||
|
||||
# kill old process if it exists & set new pid file
|
||||
stop_section_processes "$SECTION_ID"
|
||||
[ $? -gt 0 ] && write_log 7 "Send 'SIGTERM' was send to old process" || write_log 7 "No old process"
|
||||
echo $$ > $PIDFILE
|
||||
|
||||
# determine when the last update was
|
||||
# the following lines should prevent multiple updates if hotplug fires multiple startups
|
||||
# as described in Ticket #7820, but did not function if never an update take place
|
||||
# i.e. after a reboot (/var is linked to /tmp)
|
||||
# using uptime as reference because date might not be updated via NTP client
|
||||
get_uptime CURR_TIME
|
||||
[ -e "$UPDFILE" ] && {
|
||||
LAST_TIME=$(cat $UPDFILE)
|
||||
# check also LAST > CURR because link of /var/run to /tmp might be removed
|
||||
# i.e. boxes with larger filesystems
|
||||
[ -z "$LAST_TIME" ] && LAST_TIME=0
|
||||
[ $LAST_TIME -gt $CURR_TIME ] && LAST_TIME=0
|
||||
}
|
||||
if [ $LAST_TIME -eq 0 ]; then
|
||||
write_log 7 "last update: never"
|
||||
else
|
||||
EPOCH_TIME=$(( $(date +%s) - CURR_TIME + LAST_TIME ))
|
||||
EPOCH_TIME="date -d @$EPOCH_TIME +'$DATE_FORMAT'"
|
||||
write_log 7 "last update: $(eval $EPOCH_TIME)"
|
||||
fi
|
||||
|
||||
# verify DNS server
|
||||
[ -n "$dns_server" ] && verify_dns "$dns_server"
|
||||
|
||||
# verify Proxy server and set environment
|
||||
[ -n "$proxy" ] && {
|
||||
verify_proxy "$proxy" && {
|
||||
# everything ok set proxy
|
||||
export HTTP_PROXY="http://$proxy"
|
||||
export HTTPS_PROXY="http://$proxy"
|
||||
export http_proxy="http://$proxy"
|
||||
export https_proxy="http://$proxy"
|
||||
}
|
||||
}
|
||||
|
||||
# let's check if there is already an IP registered on the web
|
||||
get_registered_ip REGISTERED_IP "NO_RETRY"
|
||||
ERR_LAST=$?
|
||||
# No error or No IP set otherwise retry
|
||||
[ $ERR_LAST -eq 0 -o $ERR_LAST -eq 127 ] || get_registered_ip REGISTERED_IP
|
||||
|
||||
# loop endlessly, checking ip every check_interval and forcing an updating once every force_interval
|
||||
write_log 6 "Starting main loop at $(eval $DATE_PROG)"
|
||||
while : ; do
|
||||
|
||||
get_local_ip LOCAL_IP # read local IP
|
||||
|
||||
# prepare update
|
||||
# never updated or forced immediate then NEXT_TIME = 0
|
||||
[ $FORCE_SECONDS -eq 0 -o $LAST_TIME -eq 0 ] \
|
||||
&& NEXT_TIME=0 \
|
||||
|| NEXT_TIME=$(( $LAST_TIME + $FORCE_SECONDS ))
|
||||
|
||||
get_uptime CURR_TIME # get current uptime
|
||||
|
||||
# send update when current time > next time or local ip different from registered ip
|
||||
if [ $CURR_TIME -ge $NEXT_TIME -o "$LOCAL_IP" != "$REGISTERED_IP" ]; then
|
||||
if [ $VERBOSE_MODE -gt 2 ]; then
|
||||
write_log 7 "Verbose Mode: $VERBOSE_MODE - NO UPDATE send"
|
||||
elif [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
|
||||
write_log 7 "Update needed - L: '$LOCAL_IP' <> R: '$REGISTERED_IP'"
|
||||
else
|
||||
write_log 7 "Forced Update - L: '$LOCAL_IP' == R: '$REGISTERED_IP'"
|
||||
fi
|
||||
|
||||
ERR_LAST=0
|
||||
[ $VERBOSE_MODE -lt 3 ] && {
|
||||
# only send if VERBOSE_MODE < 3
|
||||
send_update "$LOCAL_IP"
|
||||
ERR_LAST=$? # save return value
|
||||
}
|
||||
|
||||
# error sending local IP to provider
|
||||
# we have no communication error (handled inside send_update/do_transfer)
|
||||
# but update was not recognized
|
||||
# do NOT retry after RETRY_SECONDS, do retry after CHECK_SECONDS
|
||||
# to early retrys will block most DDNS provider
|
||||
# providers answer is checked inside send_update() function
|
||||
if [ $ERR_LAST -eq 0 ]; then
|
||||
get_uptime LAST_TIME # we send update, so
|
||||
echo $LAST_TIME > $UPDFILE # save LASTTIME to file
|
||||
[ "$LOCAL_IP" != "$REGISTERED_IP" ] \
|
||||
&& 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"
|
||||
fi
|
||||
fi
|
||||
|
||||
# now we wait for check interval before testing if update was recognized
|
||||
# only sleep if VERBOSE_MODE <= 2 because otherwise nothing was send
|
||||
[ $VERBOSE_MODE -le 2 ] && {
|
||||
write_log 7 "Waiting $CHECK_SECONDS seconds (Check Interval)"
|
||||
sleep $CHECK_SECONDS &
|
||||
PID_SLEEP=$!
|
||||
wait $PID_SLEEP # enable trap-handler
|
||||
PID_SLEEP=0
|
||||
} || write_log 7 "Verbose Mode: $VERBOSE_MODE - NO Check Interval waiting"
|
||||
|
||||
REGISTERED_IP="" # clear variable
|
||||
get_registered_ip REGISTERED_IP # get registered/public IP
|
||||
|
||||
# IP's are still different
|
||||
if [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
|
||||
if [ $VERBOSE_MODE -le 1 ]; then # VERBOSE_MODE <=1 then retry
|
||||
ERR_UPDATE=$(( $ERR_UPDATE + 1 ))
|
||||
[ $retry_count -gt 0 -a $ERR_UPDATE -gt $retry_count ] && \
|
||||
write_log 14 "Updating IP at DDNS provider failed after $retry_count retries"
|
||||
write_log 4 "Updating IP at DDNS provider failed - starting retry $ERR_UPDATE/$retry_count"
|
||||
continue # loop to beginning
|
||||
else
|
||||
write_log 4 "Updating IP at DDNS provider failed"
|
||||
write_log 7 "Verbose Mode: $VERBOSE_MODE - NO retry"; exit 1
|
||||
fi
|
||||
else
|
||||
# we checked successful the last update
|
||||
ERR_UPDATE=0 # reset error counter
|
||||
fi
|
||||
|
||||
# force_update=0 or VERBOSE_MODE > 1 - leave here
|
||||
[ $VERBOSE_MODE -gt 1 ] && write_log 7 "Verbose Mode: $VERBOSE_MODE - NO reloop"
|
||||
[ $FORCE_SECONDS -eq 0 ] && write_log 6 "Configured to run once"
|
||||
[ $VERBOSE_MODE -gt 1 -o $FORCE_SECONDS -eq 0 ] && exit 0
|
||||
|
||||
write_log 6 "Rerun IP check at $(eval $DATE_PROG)"
|
||||
done
|
||||
# we should never come here there must be a programming error
|
||||
write_log 12 "Error in 'dynamic_dns_updater.sh - program coding error"
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# sample script for detecting local IP
|
||||
# 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
#
|
||||
# activated inside /etc/config/ddns by setting
|
||||
#
|
||||
# option ip_source 'script'
|
||||
# option ip_script '/usr/lib/ddns/getlocalip_sample.sh -6' !!! parameters ALLOWED
|
||||
#
|
||||
# the script is executed (not parsed) inside get_local_ip() function
|
||||
# of /usr/lib/ddns/dynamic_dns_functions.sh
|
||||
#
|
||||
# useful when this box is the only DDNS client in the network
|
||||
# IP adresses of "internal" boxes could be detected with this script
|
||||
# so no need to install ddns client on every "internal" box
|
||||
# On IPv6 every internal box normally has it's own external IP
|
||||
#
|
||||
# This script should
|
||||
# - return the IP address via stdout echo -n "...." !!! without line feed
|
||||
# - report errors via stderr echo "...." >&2
|
||||
# - return an error code ('0' for success) exit 123
|
||||
|
||||
case $1 in
|
||||
-4) echo -n "8.8.8.8" # never append linefeed or simular
|
||||
exit 0
|
||||
;; # IP's of Googles public DNS
|
||||
-6) echo -n "2001:4860:4860::8888"
|
||||
exit 0
|
||||
;;
|
||||
*) echo "$0 - Invalid or missing parameter" >&2
|
||||
exit 1
|
||||
esac
|
||||
echo "Should never come here" >&2
|
||||
exit 2
|
||||
@@ -1,98 +0,0 @@
|
||||
# 44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
|
||||
#
|
||||
# This file contains the update urls for various dynamic dns services.
|
||||
# Column one contains the service name, column two contains the update url.
|
||||
# within the update url there are 4 variables you can use: [USERNAME],
|
||||
# [PASSWORD], [DOMAIN] and [IP]. These are substituted for the username,
|
||||
# password, and domain name specified in the /etc/config/ddns file when an
|
||||
# update is performed. The IP is substituted for the current ip address of the
|
||||
# router. These variables are case sensitive, while urls generally are not, so
|
||||
# if you need to enter the same text in the url (which seems very unlikely) put
|
||||
# that text in lowercase, while the variables should remain in uppercase
|
||||
#
|
||||
# There are TONS of dynamic dns services out there. There's a huge list of them at:
|
||||
# http://www.dmoz.org/Computers/Software/Internet/Servers/Address_Management/Dynamic_DNS_Services/
|
||||
# If anyone has time they could update this file to be compatible with a bunch of them
|
||||
#
|
||||
# !!! Since ddns-scripts Version 2.x the update of IPv6 addresses is also supported
|
||||
# !!! This file is used for update of IPv4 adresses only. For IPv6 use services_ipv6
|
||||
#
|
||||
# !!! Since ddns-scripts Version 2.x the update via provider specific update scripts is supported.
|
||||
# !!! This scripts must be located at /usr/lib/ddns directory if defined inside this file.
|
||||
# !!! Use only the script name (without path). Sample:
|
||||
# !!! "example.com" "update_sample.sh"
|
||||
#
|
||||
# 44444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
|
||||
|
||||
"dyndns.org" "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]"
|
||||
"changeip.com" "http://[USERNAME]:[PASSWORD]@nic.changeip.com/nic/update?u=[USERNAME]&p=[PASSWORD]&cmd=update&hostname=[DOMAIN]&ip=[IP]"
|
||||
"zoneedit.com" "http://[USERNAME]:[PASSWORD]@dynamic.zoneedit.com/auth/dynamic.html?host=[DOMAIN]&dnsto=[IP]"
|
||||
"free.editdns.net" "http://dyndns-free.editdns.net/api/dynLinux.php?p=[PASSWORD]&r=[DOMAIN]"
|
||||
|
||||
# noip is an alias of no-ip, so allow both names for the same service
|
||||
# use provider specific update script
|
||||
"no-ip.com" "update_no-ip.sh"
|
||||
"noip.com" "update_no-ip.sh"
|
||||
|
||||
# freedns.afraid.org is weird, you just need an update code, for which we use the password variable
|
||||
"freedns.afraid.org" "http://freedns.afraid.org/dynamic/update.php?[PASSWORD]&address=[IP]"
|
||||
|
||||
# DNS Max and resellers' update urls
|
||||
"dnsmax.com" "http://update.dnsmax.com/update/?username=[USERNAME]&password=[PASSWORD]&resellerid=1&clientname=openwrt&clientversion=8.09&protocolversion=2.0&updatehostname=[DOMAIN]&ip=[IP]"
|
||||
"thatip.com" "http://update.dnsmax.com/update/?username=[USERNAME]&password=[PASSWORD]&resellerid=2&clientname=openwrt&clientversion=8.09&protocolversion=2.0&updatehostname=[DOMAIN]&ip=[IP]"
|
||||
|
||||
# Hurricane Electric Dynamic DNS
|
||||
"he.net" "http://[DOMAIN]:[PASSWORD]@dyn.dns.he.net/nic/update?hostname=[DOMAIN]&myip=[IP]"
|
||||
|
||||
# DNSdynamic.org
|
||||
"dnsdynamic.org" "http://[USERNAME]:[PASSWORD]@www.dnsdynamic.org/api/?hostname=[DOMAIN]&myip=[IP]"
|
||||
|
||||
# dnsExit.com free dynamic DNS update url
|
||||
"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]"
|
||||
|
||||
# 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]"
|
||||
|
||||
# 3322.org
|
||||
"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]"
|
||||
|
||||
# easydns.com dynamic DNS
|
||||
"easydns.com" "http://[USERNAME]:[PASSWORD]@api.cp.easydns.com/dyn/tomato.php?hostname=[DOMAIN]&myip=[IP]"
|
||||
|
||||
# Winco DDNS
|
||||
"ddns.com.br" "http://[DOMAIN]:[PASSWORD]@members.ddns.com.br/nic/update?hostname=[DOMAIN]&myip=[IP]"
|
||||
|
||||
# Mythic Beasts (https://www.mythic-beasts.com) Dynamic DNS
|
||||
"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]"
|
||||
|
||||
# duiadns.net - free dynamic DNS
|
||||
"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]"
|
||||
|
||||
# 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]"
|
||||
|
||||
# Cloudflare
|
||||
"cloudflare.com" "update_cloudflare.sh"
|
||||
|
||||
# SelfHost.de
|
||||
"selfhost.de" "http://carol.selfhost.de/update?username=[USERNAME]&password=[PASSWORD]&myip=[IP]&hostname=1"
|
||||
|
||||
# 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]"
|
||||
@@ -1,43 +0,0 @@
|
||||
# 66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
|
||||
#
|
||||
# This file contains the update urls for various dynamic dns services.
|
||||
# Column one contains the service name, column two contains the update url.
|
||||
# within the update url there are 4 variables you can use: [USERNAME],
|
||||
# [PASSWORD], [DOMAIN] and [IP]. These are substituted for the username,
|
||||
# password, and domain name specified in the /etc/config/ddns file when an
|
||||
# update is performed. The IP is substituted for the current ip address of the
|
||||
# router. These variables are case sensitive, while urls generally are not, so
|
||||
# if you need to enter the same text in the url (which seems very unlikely) put
|
||||
# that text in lowercase, while the variables should remain in uppercase
|
||||
#
|
||||
# There are TONS of dynamic dns services out there. There's a huge list of them at:
|
||||
# http://www.dmoz.org/Computers/Software/Internet/Servers/Address_Management/Dynamic_DNS_Services/
|
||||
# If anyone has time they could update this file to be compatible with a bunch of them
|
||||
#
|
||||
# !!! Since ddns-scripts Version 2.x the update of IPv6 addresses is also supported
|
||||
# !!! This file is used for update of IPv6 adresses only. For IPv4 use services
|
||||
#
|
||||
# !!! Since ddns-scripts Version 2.x the update via provider specific update scripts is supported.
|
||||
# !!! This scripts must be located at /usr/lib/ddns directory if defined inside this file.
|
||||
# !!! Use only the script name (without path). Sample:
|
||||
# !!! "example.com" "update_sample.sh"
|
||||
#
|
||||
# 66666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
|
||||
|
||||
# IPv6 @ Securepoint Dynamic-DNS-Service
|
||||
"spdns.de" "http://[USERNAME]:[PASSWORD]@update.spdns.de/nic/update?hostname=[DOMAIN]&myip=[IP]"
|
||||
|
||||
# IPv6 @ Hurricane Electric Dynamic DNS
|
||||
"he.net" "http://[DOMAIN]:[PASSWORD]@dyn.dns.he.net/nic/update?hostname=[DOMAIN]&myip=[IP]"
|
||||
|
||||
# IPv6 @ MyDNS.JP
|
||||
"mydns.jp" "http://www.mydns.jp/directip.html?MID=[USERNAME]&PWD=[PASSWORD]&IPV6ADDR=[IP]"
|
||||
|
||||
# IPv6 @ Cloudflare
|
||||
"cloudflare.com" "update_cloudflare.sh"
|
||||
|
||||
# IPv6 @ 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]"
|
||||
|
||||
# IPv6 @ freedns.afraid.org
|
||||
"freedns.afraid.org" "http://freedns.afraid.org/dynamic/update.php?[PASSWORD]&address=[IP]"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,140 +0,0 @@
|
||||
#
|
||||
# script for sending updates to cloudflare.com
|
||||
# 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
# many thanks to Paul for testing and feedback during development
|
||||
#
|
||||
# This script is parsed by dynamic_dns_functions.sh inside send_update() function
|
||||
#
|
||||
# using following options from /etc/config/ddns
|
||||
# option username - your cloudflare e-mail
|
||||
# option password - cloudflare api key, you can get it from cloudflare.com/my-account/
|
||||
# option domain - your full hostname to update, in cloudflare its subdomain.domain
|
||||
# i.e. myhost.example.com where myhost is the subdomain and example.com is your domain
|
||||
#
|
||||
# variable __IP already defined with the ip-address to use for update
|
||||
#
|
||||
[ $use_https -eq 0 ] && write_log 14 "Cloudflare only support updates via Secure HTTP (HTTPS). Please correct configuration!"
|
||||
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
|
||||
[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
|
||||
|
||||
local __RECID __URL __KEY __KEYS __FOUND __SUBDOM __DOMAIN __TLD
|
||||
|
||||
# split given Host/Domain into TLD, registrable domain, and subdomain
|
||||
split_FQDN $domain __TLD __DOMAIN __SUBDOM
|
||||
[ $? -ne 0 -o -z "$__DOMAIN" ] && \
|
||||
write_log 14 "Wrong Host/Domain configuration ($domain). Please correct configuration!"
|
||||
|
||||
# put together what we need
|
||||
__DOMAIN="$__DOMAIN.$__TLD"
|
||||
|
||||
# parse OpenWrt script with
|
||||
# functions for parsing and generating json
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
# function copied from /usr/share/libubox/jshn.sh
|
||||
# from BB14.09 for backward compatibility to AA12.09
|
||||
grep -i "json_get_keys" /usr/share/libubox/jshn.sh >/dev/null 2>&1 || json_get_keys() {
|
||||
local __dest="$1"
|
||||
local _tbl_cur
|
||||
|
||||
if [ -n "$2" ]; then
|
||||
json_get_var _tbl_cur "$2"
|
||||
else
|
||||
_json_get_var _tbl_cur JSON_CUR
|
||||
fi
|
||||
local __var="${JSON_PREFIX}KEYS_${_tbl_cur}"
|
||||
eval "export -- \"$__dest=\${$__var}\"; [ -n \"\${$__var+x}\" ]"
|
||||
}
|
||||
|
||||
# function to "sed" unwanted string parts from DATFILE
|
||||
cleanup() {
|
||||
# based on the sample output on cloudflare.com homepage we need to do some cleanup
|
||||
sed -i 's/^[ \t]*//;s/[ \t]*$//' $DATFILE # remove invisible chars at beginning and end of lines
|
||||
sed -i '/^-$/d' $DATFILE # remove lines with "-" (dash)
|
||||
sed -i '/^$/d' $DATFILE # remove empty lines
|
||||
sed -i "#'##g" $DATFILE # remove "'" (single quote)
|
||||
}
|
||||
|
||||
# build url according to cloudflare client api at https://www.cloudflare.com/docs/client-api.html
|
||||
# to "rec_load_all" to detect rec_id needed for update
|
||||
__URL="https://www.cloudflare.com/api_json.html" # https://www.cloudflare.com/api_json.html
|
||||
__URL="${__URL}?a=rec_load_all" # -d 'a=rec_load_all'
|
||||
__URL="${__URL}&tkn=$password" # -d 'tkn=8afbe6dea02407989af4dd4c97bb6e25'
|
||||
__URL="${__URL}&email=$username" # -d 'email=sample@example.com'
|
||||
__URL="${__URL}&z=$__DOMAIN" # -d 'z=example.com'
|
||||
|
||||
# lets request the data
|
||||
do_transfer "$__URL" || return 1
|
||||
|
||||
cleanup # cleanup dat file
|
||||
json_load "$(cat $DATFILE)" # lets extract data
|
||||
__FOUND=0 # found record indicator
|
||||
json_get_var __RES "result" # cloudflare result of last request
|
||||
json_get_var __MSG "msg" # cloudflare error message
|
||||
[ "$__RES" != "success" ] && {
|
||||
write_log 4 "'rec_load_all' failed with error: \n$__MSG"
|
||||
return 1
|
||||
}
|
||||
|
||||
json_select "response"
|
||||
json_select "recs"
|
||||
json_select "objs"
|
||||
json_get_keys __KEYS
|
||||
for __KEY in $__KEYS; do
|
||||
local __ZONE __DISPLAY __NAME __TYPE
|
||||
json_select "$__KEY"
|
||||
# json_get_var __ZONE "zone_name" # for debugging
|
||||
# json_get_var __DISPLAY "display_name" # for debugging
|
||||
json_get_var __NAME "name"
|
||||
json_get_var __TYPE "type"
|
||||
if [ "$__NAME" = "$domain" ]; then
|
||||
# we must verify IPv4 and IPv6 because there might be both for the same host
|
||||
[ \( $use_ipv6 -eq 0 -a "$__TYPE" = "A" \) -o \( $use_ipv6 -eq 1 -a "$__TYPE" = "AAAA" \) ] && {
|
||||
__FOUND=1 # mark found
|
||||
break # found leave for loop
|
||||
}
|
||||
fi
|
||||
json_select ..
|
||||
done
|
||||
[ $__FOUND -eq 0 ] && {
|
||||
# we don't need to continue trying to update cloudflare because record to update does not exist
|
||||
# user has to setup record first outside ddns-scripts
|
||||
write_log 14 "No valid record found at Cloudflare setup. Please create first!"
|
||||
}
|
||||
json_get_var __RECID "rec_id" # last thing to do get rec_id
|
||||
json_cleanup # cleanup
|
||||
write_log 7 "rec_id '$__RECID' detected for host/domain '$domain'"
|
||||
|
||||
# build url according to cloudflare client api at https://www.cloudflare.com/docs/client-api.html
|
||||
# for "rec_edit" to update IP address
|
||||
__URL="https://www.cloudflare.com/api_json.html" # https://www.cloudflare.com/api_json.html
|
||||
__URL="${__URL}?a=rec_edit" # -d 'a=rec_edit'
|
||||
__URL="${__URL}&tkn=$password" # -d 'tkn=8afbe6dea02407989af4dd4c97bb6e25'
|
||||
__URL="${__URL}&id=$__RECID" # -d 'id=9001'
|
||||
__URL="${__URL}&email=$username" # -d 'email=sample@example.com'
|
||||
__URL="${__URL}&z=$__DOMAIN" # -d 'z=example.com'
|
||||
|
||||
[ $use_ipv6 -eq 0 ] && __URL="${__URL}&type=A" # -d 'type=A' (IPv4)
|
||||
[ $use_ipv6 -eq 1 ] && __URL="${__URL}&type=AAAA" # -d 'type=AAAA' (IPv6)
|
||||
|
||||
# handle subdomain or domain record
|
||||
[ -n "$__SUBDOM" ] && __URL="${__URL}&name=$__SUBDOM" # -d 'name=sub' (HOST/SUBDOMAIN)
|
||||
[ -z "$__SUBDOM" ] && __URL="${__URL}&name=$__DOMAIN" # -d 'name=example.com'(DOMAIN)
|
||||
|
||||
__URL="${__URL}&content=$__IP" # -d 'content=1.2.3.4'
|
||||
__URL="${__URL}&service_mode=0" # -d 'service_mode=0'
|
||||
__URL="${__URL}&ttl=1" # -d 'ttl=1'
|
||||
|
||||
# lets do the update
|
||||
do_transfer "$__URL" || return 1
|
||||
|
||||
cleanup # cleanup tmp file
|
||||
json_load "$(cat $DATFILE)" # lets extract data
|
||||
json_get_var __RES "result" # cloudflare result of last request
|
||||
json_get_var __MSG "msg" # cloudflare error message
|
||||
[ "$__RES" != "success" ] && {
|
||||
write_log 4 "'rec_edit' failed with error:\n$__MSG"
|
||||
return 1
|
||||
}
|
||||
write_log 7 "Update of rec_id '$__RECID' successful"
|
||||
return 0
|
||||
@@ -1,50 +0,0 @@
|
||||
#
|
||||
# script for sending updates to no-ip.com / noip.com
|
||||
# 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
#
|
||||
# This script is parsed by dynamic_dns_functions.sh inside send_update() function
|
||||
#
|
||||
# provider did not reactivate records, if no IP change was recognized
|
||||
# so we send a dummy (localhost) and a seconds later we send the correct IP addr
|
||||
#
|
||||
local __DUMMY
|
||||
local __UPDURL="http://[USERNAME]:[PASSWORD]@dynupdate.no-ip.com/nic/update?hostname=[DOMAIN]&myip=[IP]"
|
||||
# inside url we need username and password
|
||||
[ -z "$username" ] && write_log 14 "Service section not configured correctly! Missing 'username'"
|
||||
[ -z "$password" ] && write_log 14 "Service section not configured correctly! Missing 'password'"
|
||||
|
||||
# set IP version dependend dummy (localhost)
|
||||
[ $use_ipv6 -eq 0 ] && __DUMMY="127.0.0.1" || __DUMMY="::1"
|
||||
|
||||
# lets do DUMMY transfer
|
||||
write_log 7 "sending dummy IP to 'no-ip.com'"
|
||||
__URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#g" \
|
||||
-e "s#\[DOMAIN\]#$domain#g" -e "s#\[IP\]#$__DUMMY#g")
|
||||
[ $use_https -ne 0 ] && __URL=$(echo $__URL | sed -e 's#^http:#https:#')
|
||||
|
||||
do_transfer "$__URL" || return 1
|
||||
|
||||
write_log 7 "'no-ip.com' 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 || return 1
|
||||
|
||||
# lets wait a seconds
|
||||
sleep 1
|
||||
|
||||
# now send the correct data
|
||||
write_log 7 "sending real IP to 'no-ip.com'"
|
||||
__URL=$(echo $__UPDURL | sed -e "s#\[USERNAME\]#$URL_USER#g" -e "s#\[PASSWORD\]#$URL_PASS#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 "'no-ip.com' 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
|
||||
return $? # "0" if "good" or "nochg" found
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
# sample script for sending user defined updates
|
||||
# 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
#
|
||||
# activated inside /etc/config/ddns by setting
|
||||
#
|
||||
# option update_script '/usr/lib/ddns/update_sample.sh'
|
||||
#
|
||||
# the script is parsed (not executed) inside send_update() function
|
||||
# of /usr/lib/ddns/dynamic_dns_functions.sh
|
||||
# so you can use all available functions and global variables inside this script
|
||||
# already defined in dynamic_dns_updater.sh and dynamic_dns_functions.sh
|
||||
#
|
||||
# It make sence to define the update url ONLY inside this script
|
||||
# because it's anyway unique to the update script
|
||||
# otherwise it should work with the default scripts
|
||||
#
|
||||
# the code here is the copy of the default used inside send_update()
|
||||
#
|
||||
# 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
|
||||
[ -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")
|
||||
[ $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)"
|
||||
|
||||
# analyse provider answers
|
||||
# "good [IP_ADR]" = successful
|
||||
# "nochg [IP_ADR]" = no change but OK
|
||||
grep -E "good|nochg" $DATFILE >/dev/null 2>&1
|
||||
return $? # "0" if "good" or "nochg" found
|
||||
|
||||
Reference in New Issue
Block a user