Merge pull request #792 from chris5560/master
ddns-scripts: Update to Version 2.1.0-5
This commit is contained in:
commit
0d5c284b49
10 changed files with 141 additions and 126 deletions
|
@ -2,8 +2,9 @@ include $(TOPDIR)/rules.mk
|
|||
|
||||
PKG_NAME:=ddns-scripts
|
||||
PKG_VERSION:=2.1.0
|
||||
PKG_RELEASE:=4
|
||||
PKG_RELEASE:=5
|
||||
PKG_LICENSE:=GPL-2.0
|
||||
PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
|
@ -15,7 +16,6 @@ define Package/ddns-scripts
|
|||
SUBMENU:=IP Addresses and Names
|
||||
TITLE:=Dynamic DNS Scripts (with IPv6 support)
|
||||
PKGARCH:=all
|
||||
MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>
|
||||
endef
|
||||
|
||||
define Package/ddns-scripts/description
|
||||
|
@ -28,7 +28,6 @@ A highly configurable set of scripts for doing dynamic dns updates.
|
|||
- Proxy server support
|
||||
- log file support
|
||||
- support to run once
|
||||
Version: $(PKG_VERSION)-$(PKG_RELEASE)
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
|
|
|
@ -17,8 +17,6 @@
|
|||
|
||||
. /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"
|
||||
|
|
|
@ -115,28 +115,8 @@ trap "trap_handler 15" 15 # SIGTERM Termination
|
|||
#
|
||||
################################################################################
|
||||
|
||||
# verify and load SECTION_ID is exists
|
||||
[ "$(uci -q get ddns.$SECTION_ID)" != "service" ] && {
|
||||
[ $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"
|
||||
}
|
||||
load_all_config_options "ddns" "$SECTION_ID"
|
||||
|
||||
write_log 7 "************ ************** ************** **************"
|
||||
write_log 5 "PID '$$' started at $(eval $DATE_PROG)"
|
||||
write_log 7 "uci configuraion:\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
|
||||
ERR_LAST=$? # save return code - equal 0 if SECTION_ID found
|
||||
|
||||
# set defaults if not defined
|
||||
[ -z "$enabled" ] && enabled=0
|
||||
|
@ -154,15 +134,54 @@ esac
|
|||
[ "$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!"
|
||||
|
||||
# without domain or username or password we can do nothing for you
|
||||
[ -z "$domain" -o -z "$username" -o -z "$password" ] && write_log 14 "Service section not correctly configured!"
|
||||
urlencode URL_USER "$username" # encode username, might be email or something like this
|
||||
urlencode URL_PASS "$password" # encode password, might have special chars for security reason
|
||||
# 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!"
|
||||
|
||||
# verify ip_source script if configured and executable
|
||||
# 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!"
|
||||
|
@ -180,16 +199,9 @@ write_log 7 "force interval: $FORCE_SECONDS seconds"
|
|||
write_log 7 "retry interval: $RETRY_SECONDS seconds"
|
||||
write_log 7 "retry counter : $retry_count times"
|
||||
|
||||
# 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!"
|
||||
|
||||
# kill old process if it exists & set new pid file
|
||||
stop_section_processes "$SECTION_ID"
|
||||
[ $? -gt 0 ] && write_log 7 "Send 'SIGTERM' to old process" || write_log 7 "No old process"
|
||||
[ $? -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
|
||||
|
@ -213,14 +225,6 @@ else
|
|||
write_log 7 "last update: $(eval $EPOCH_TIME)"
|
||||
fi
|
||||
|
||||
# we need time here because hotplug.d is fired by netifd
|
||||
# but IP addresses are not set by DHCP/DHCPv6 etc.
|
||||
write_log 7 "Waiting 10 seconds for interfaces to fully come up"
|
||||
sleep 10 &
|
||||
PID_SLEEP=$!
|
||||
wait $PID_SLEEP # enable trap-handler
|
||||
PID_SLEEP=0
|
||||
|
||||
# verify DNS server
|
||||
[ -n "$dns_server" ] && verify_dns "$dns_server"
|
||||
|
||||
|
@ -235,9 +239,11 @@ PID_SLEEP=0
|
|||
}
|
||||
}
|
||||
|
||||
# let's check if there is already an IP registered at the web
|
||||
# but ignore errors if not
|
||||
# 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)"
|
||||
|
@ -279,8 +285,9 @@ while : ; do
|
|||
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"
|
||||
[ "$LOCAL_IP" = "$REGISTERED_IP" ] || write_log 6 "Forced update successful - IP: '$LOCAL_IP' send"
|
||||
[ "$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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# sample script for detecting local IP
|
||||
# 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
# 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
#
|
||||
# activated inside /etc/config/ddns by setting
|
||||
#
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
#444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
|
||||
#4
|
||||
#4 This file contains the update urls for various dynamic dns services.
|
||||
#4 Column one contains the service name, column two contains the update url.
|
||||
#4 within the update url there are 4 variables you can use: [USERNAME],
|
||||
#4 [PASSWORD], [DOMAIN] and [IP]. These are substituted for the username,
|
||||
#4 password, and domain name specified in the /etc/config/ddns file when an
|
||||
#4 update is performed. The IP is substituted for the current ip address of the
|
||||
#4 router. These variables are case sensitive, while urls generally are not, so
|
||||
#4 if you need to enter the same text in the url (which seems very unlikely) put
|
||||
#4 that text in lowercase, while the variables should remain in uppercase
|
||||
#4
|
||||
#4 There are TONS of dynamic dns services out there. There's a huge list of them at:
|
||||
#4 http://www.dmoz.org/Computers/Software/Internet/Servers/Address_Management/Dynamic_DNS_Services/
|
||||
#4 If anyone has time they could update this file to be compatible with a bunch of them
|
||||
#4
|
||||
#4 !!! Since ddns-scripts Version 2.x the update of IPv6 addresses is also supported
|
||||
#4 !!! This file is used for update of IPv4 adresses only. For IPv6 use services_ipv6
|
||||
#4
|
||||
#4 !!! Since ddns-scripts Version 2.x the update via provider specific update scripts is supported.
|
||||
#4 !!! This scripts must be located at /usr/lib/ddns directory if defined inside this file.
|
||||
#4 !!! Use only the script name (without path). Sample:
|
||||
#4 !!! "example.com" "update_sample.sh"
|
||||
#4
|
||||
#444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444
|
||||
# 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]"
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
#666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
|
||||
#6
|
||||
#6 This file contains the update urls for various dynamic dns services.
|
||||
#6 Column one contains the service name, column two contains the update url.
|
||||
#6 within the update url there are 4 variables you can use: [USERNAME],
|
||||
#6 [PASSWORD], [DOMAIN] and [IP]. These are substituted for the username,
|
||||
#6 password, and domain name specified in the /etc/config/ddns file when an
|
||||
#6 update is performed. The IP is substituted for the current ip address of the
|
||||
#6 router. These variables are case sensitive, while urls generally are not, so
|
||||
#6 if you need to enter the same text in the url (which seems very unlikely) put
|
||||
#6 that text in lowercase, while the variables should remain in uppercase
|
||||
#6
|
||||
#6 There are TONS of dynamic dns services out there. There's a huge list of them at:
|
||||
#6 http://www.dmoz.org/Computers/Software/Internet/Servers/Address_Management/Dynamic_DNS_Services/
|
||||
#6 If anyone has time they could update this file to be compatible with a bunch of them
|
||||
#6
|
||||
#6 !!! Since ddns-scripts Version 2.x the update of IPv6 addresses is also supported
|
||||
#6 !!! This file is used for update of IPv6 adresses only. For IPv4 use services
|
||||
#6
|
||||
#6 !!! Since ddns-scripts Version 2.x the update via provider specific update scripts is supported.
|
||||
#6 !!! This scripts must be located at /usr/lib/ddns directory if defined inside this file.
|
||||
#6 !!! Use only the script name (without path). Sample:
|
||||
#6 !!! "example.com" "update_sample.sh"
|
||||
#6
|
||||
#666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
|
||||
# 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]"
|
||||
|
@ -38,3 +38,6 @@
|
|||
|
||||
# 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]"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# script for sending updates to cloudflare.com
|
||||
# 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot 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
|
||||
|
@ -14,6 +14,8 @@
|
|||
# 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
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# script for sending updates to no-ip.com / noip.com
|
||||
# 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot 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
|
||||
#
|
||||
|
@ -9,6 +9,9 @@
|
|||
#
|
||||
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"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# sample script for sending user defined updates
|
||||
# 2014 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
# 2014-2015 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
|
||||
#
|
||||
# activated inside /etc/config/ddns by setting
|
||||
#
|
||||
|
@ -18,6 +18,9 @@
|
|||
#
|
||||
# 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" \
|
||||
|
|
Loading…
Reference in a new issue