Browse Source

Merge pull request #5430 from chris5560/master

ddns-scripts: multiple fixes
lilik-openwrt-22.03
Hannu Nyman 7 years ago
committed by GitHub
parent
commit
a5fdaeb52c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 17 deletions
  1. +2
    -2
      net/ddns-scripts/Makefile
  2. +10
    -4
      net/ddns-scripts/files/dynamic_dns_functions.sh
  3. +2
    -1
      net/ddns-scripts/files/dynamic_dns_lucihelper.sh
  4. +2
    -1
      net/ddns-scripts/files/dynamic_dns_updater.sh
  5. +4
    -0
      net/ddns-scripts/files/services
  6. +1
    -1
      net/ddns-scripts/files/services_ipv6
  7. +14
    -7
      net/ddns-scripts/files/update_cloudflare_com_v4.sh
  8. +2
    -1
      net/ddns-scripts/files/update_godaddy_com_v1.sh

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

@ -1,5 +1,5 @@
# #
# Copyright (C) 2008-2017 OpenWrt.org
# Copyright (C) 2008-2018 OpenWrt.org
# #
# This is free software, licensed under the GNU General Public License v2. # This is free software, licensed under the GNU General Public License v2.
# #
@ -12,7 +12,7 @@ PKG_NAME:=ddns-scripts
PKG_VERSION:=2.7.7 PKG_VERSION:=2.7.7
# Release == build # Release == build
# increase on changes of services files or tld_names.dat # increase on changes of services files or tld_names.dat
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_LICENSE:=GPL-2.0 PKG_LICENSE:=GPL-2.0
PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com> PKG_MAINTAINER:=Christian Schoenebeck <christian.schoenebeck@gmail.com>


+ 10
- 4
net/ddns-scripts/files/dynamic_dns_functions.sh View File

@ -6,7 +6,7 @@
# (Loosely) based on the script on the one posted by exobyte in the forums here: # (Loosely) based on the script on the one posted by exobyte in the forums here:
# http://forum.openwrt.org/viewtopic.php?id=14040 # http://forum.openwrt.org/viewtopic.php?id=14040
# extended and partial rewritten # extended and partial rewritten
#.2014-2017 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
#.2014-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
# #
# function timeout # function timeout
# copied from http://www.ict.griffith.edu.au/anthony/software/timeout.sh # copied from http://www.ict.griffith.edu.au/anthony/software/timeout.sh
@ -21,7 +21,7 @@
. /lib/functions/network.sh . /lib/functions/network.sh
# GLOBAL VARIABLES # # GLOBAL VARIABLES #
VERSION="2.7.6-13"
VERSION="2.7.7-2"
SECTION_ID="" # hold config's section name SECTION_ID="" # hold config's section name
VERBOSE=0 # default mode is log to console, but easily changed with parameter VERBOSE=0 # default mode is log to console, but easily changed with parameter
MYPROG=$(basename $0) # my program call name MYPROG=$(basename $0) # my program call name
@ -31,6 +31,7 @@ PIDFILE="" # pid file
UPDFILE="" # store UPTIME of last update UPDFILE="" # store UPTIME of last update
DATFILE="" # save stdout data of WGet and other external programs called DATFILE="" # save stdout data of WGet and other external programs called
ERRFILE="" # save stderr output of WGet and other external programs called ERRFILE="" # save stderr output of WGet and other external programs called
IPFILE="" # store registered IP for read by LuCI status
TLDFILE=/usr/share/public_suffix_list.dat.gz # TLD file used by split_FQDN TLDFILE=/usr/share/public_suffix_list.dat.gz # TLD file used by split_FQDN
CHECK_SECONDS=0 # calculated seconds out of given CHECK_SECONDS=0 # calculated seconds out of given
@ -81,7 +82,7 @@ CURL=$(which curl)
# CURL_SSL not empty then SSL support available # CURL_SSL not empty then SSL support available
CURL_SSL=$($(which curl) -V 2>/dev/null | grep "Protocols:" | grep -F "https") CURL_SSL=$($(which curl) -V 2>/dev/null | grep "Protocols:" | grep -F "https")
# CURL_PROXY not empty then Proxy support available # CURL_PROXY not empty then Proxy support available
CURL_PROXY=$(find /lib /usr/lib -name libcurl.so* -exec grep -i "all_proxy" {} 2>/dev/null \;)
CURL_PROXY=$(find /lib /usr/lib -name libcurl.so* -exec strings {} 2>/dev/null \; | grep -im1 "all_proxy")
UCLIENT_FETCH=$(which uclient-fetch) UCLIENT_FETCH=$(which uclient-fetch)
# UCLIENT_FETCH_SSL not empty then SSL support available # UCLIENT_FETCH_SSL not empty then SSL support available
@ -261,7 +262,9 @@ write_log() {
[ $VERBOSE -gt 0 -o $__EXIT -gt 0 ] && echo -e "$__MSG" [ $VERBOSE -gt 0 -o $__EXIT -gt 0 ] && echo -e "$__MSG"
# write to logfile # write to logfile
if [ ${use_logfile:-1} -eq 1 -o $VERBOSE -gt 1 ]; then if [ ${use_logfile:-1} -eq 1 -o $VERBOSE -gt 1 ]; then
echo -e "$__MSG" >> $LOGFILE
printf "%s\n" "$__MSG" | \
sed -e "s/$password/*password*/g; \
s/$URL_PASS/*URL_PASS*/g" >> $LOGFILE
# VERBOSE > 1 then NO loop so NO truncate log to $ddns_loglines lines # VERBOSE > 1 then NO loop so NO truncate log to $ddns_loglines lines
[ $VERBOSE -gt 1 ] || sed -i -e :a -e '$q;N;'$ddns_loglines',$D;ba' $LOGFILE [ $VERBOSE -gt 1 ] || sed -i -e :a -e '$q;N;'$ddns_loglines',$D;ba' $LOGFILE
fi fi
@ -894,6 +897,7 @@ get_local_ip () {
while : ; do while : ; do
if [ -n "$ip_network" ]; then if [ -n "$ip_network" ]; then
# set correct program # set correct program
network_flush_cache # force re-read data from ubus
[ $use_ipv6 -eq 0 ] && __RUNPROG="network_get_ipaddr" \ [ $use_ipv6 -eq 0 ] && __RUNPROG="network_get_ipaddr" \
|| __RUNPROG="network_get_ipaddr6" || __RUNPROG="network_get_ipaddr6"
eval "$__RUNPROG __DATA $ip_network" || \ eval "$__RUNPROG __DATA $ip_network" || \
@ -1140,12 +1144,14 @@ get_registered_ip() {
fi fi
[ -n "$__DATA" ] && { [ -n "$__DATA" ] && {
write_log 7 "Registered IP '$__DATA' detected" write_log 7 "Registered IP '$__DATA' detected"
echo "$__DATA" > $IPFILE
eval "$1=\"$__DATA\"" # valid data found eval "$1=\"$__DATA\"" # valid data found
return 0 # leave here return 0 # leave here
} }
write_log 4 "NO valid IP found" write_log 4 "NO valid IP found"
__ERR=127 __ERR=127
fi fi
echo "" > $IPFILE
[ -n "$LUCI_HELPER" ] && return $__ERR # no retry if called by LuCI helper script [ -n "$LUCI_HELPER" ] && return $__ERR # no retry if called by LuCI helper script
[ -n "$2" ] && return $__ERR # $2 is given -> no retry [ -n "$2" ] && return $__ERR # $2 is given -> no retry


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

@ -2,7 +2,7 @@
# /usr/lib/ddns/dynamic_dns_lucihelper.sh # /usr/lib/ddns/dynamic_dns_lucihelper.sh
# #
#.Distributed under the terms of the GNU General Public License (GPL) version 2.0 #.Distributed under the terms of the GNU General Public License (GPL) version 2.0
#.2014-2017 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
#.2014-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
# This script is used by luci-app-ddns # This script is used by luci-app-ddns
# #
# variables in small chars are read from /etc/config/ddns as parameter given here # variables in small chars are read from /etc/config/ddns as parameter given here
@ -104,6 +104,7 @@ case "$1" in
get_registered_ip) get_registered_ip)
[ -z "$lookup_host" ] && usage_err "command 'get_registered_ip': 'lookup_host' not set" [ -z "$lookup_host" ] && usage_err "command 'get_registered_ip': 'lookup_host' not set"
write_log 7 "-----> get_registered_ip IP" write_log 7 "-----> get_registered_ip IP"
[ -z "$SECTION" ] || IPFILE="$ddns_rundir/$SECTION.ip"
IP="" IP=""
get_registered_ip IP get_registered_ip IP
__RET=$? __RET=$?


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

@ -6,7 +6,7 @@
# (Loosely) based on the script on the one posted by exobyte in the forums here: # (Loosely) based on the script on the one posted by exobyte in the forums here:
# http://forum.openwrt.org/viewtopic.php?id=14040 # http://forum.openwrt.org/viewtopic.php?id=14040
# extended and partial rewritten # extended and partial rewritten
#.2014-2017 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
#.2014-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
# #
# variables in small chars are read from /etc/config/ddns # 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 are defined inside these scripts as global vars
@ -101,6 +101,7 @@ PIDFILE="$ddns_rundir/$SECTION_ID.pid" # Process ID file
UPDFILE="$ddns_rundir/$SECTION_ID.update" # last update successful send (system uptime) UPDFILE="$ddns_rundir/$SECTION_ID.update" # last update successful send (system uptime)
DATFILE="$ddns_rundir/$SECTION_ID.dat" # save stdout data of WGet and other extern programs called 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 ERRFILE="$ddns_rundir/$SECTION_ID.err" # save stderr output of WGet and other extern programs called
IPFILE="$ddns_rundir/$SECTION_ID.ip" #
LOGFILE="$ddns_logdir/$SECTION_ID.log" # log file LOGFILE="$ddns_logdir/$SECTION_ID.log" # log file
# VERBOSE > 1 delete logfile if exist to create an empty one # VERBOSE > 1 delete logfile if exist to create an empty one


+ 4
- 0
net/ddns-scripts/files/services View File

@ -67,6 +67,8 @@
"dnsdynamic.org" "http://[USERNAME]:[PASSWORD]@www.dnsdynamic.org/api/?hostname=[DOMAIN]&myip=[IP]" "good|nochg" "dnsdynamic.org" "http://[USERNAME]:[PASSWORD]@www.dnsdynamic.org/api/?hostname=[DOMAIN]&myip=[IP]" "good|nochg"
"dnsever.com" "http://[USERNAME]:[PASSWORD]@dyna.dnsever.com/update.php?host[[DOMAIN]]"
"dnsexit.com" "http://update.dnsexit.com/RemoteUpdate.sv?login=[USERNAME]&password=[PASSWORD]&host=[DOMAIN]&myip=[IP]" "dnsexit.com" "http://update.dnsexit.com/RemoteUpdate.sv?login=[USERNAME]&password=[PASSWORD]&host=[DOMAIN]&myip=[IP]"
"dnshome.de" "http://[USERNAME]:[PASSWORD]@www.dnshome.de/dyndns.php?hostname=[DOMAIN]&ip=[IP]" "dnshome.de" "http://[USERNAME]:[PASSWORD]@www.dnshome.de/dyndns.php?hostname=[DOMAIN]&ip=[IP]"
@ -122,6 +124,8 @@
"mydns.jp" "http://www.mydns.jp/directip.html?MID=[USERNAME]&PWD=[PASSWORD]&IPV4ADDR=[IP]" "mydns.jp" "http://www.mydns.jp/directip.html?MID=[USERNAME]&PWD=[PASSWORD]&IPV4ADDR=[IP]"
"myip.co.ua" "http://[USERNAME]:[PASSWORD]@myip.co.ua/update?hostname=[DOMAIN]&myip=[IP]" "good"
"myonlineportal.net" "http://[USERNAME]:[PASSWORD]@myonlineportal.net/updateddns?hostname=[DOMAIN]&ip=[IP]" "good|nochg" "myonlineportal.net" "http://[USERNAME]:[PASSWORD]@myonlineportal.net/updateddns?hostname=[DOMAIN]&ip=[IP]" "good|nochg"
"mythic-beasts.com" "http://dnsapi4.mythic-beasts.com/?domain=[USERNAME]&password=[PASSWORD]&command=REPLACE%20[DOMAIN]%2060%20A%20DYNAMIC_IP&origin=." "mythic-beasts.com" "http://dnsapi4.mythic-beasts.com/?domain=[USERNAME]&password=[PASSWORD]&command=REPLACE%20[DOMAIN]%2060%20A%20DYNAMIC_IP&origin=."


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

@ -66,7 +66,7 @@
"dyn.com" "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]" "good|nochg" "dyn.com" "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]" "good|nochg"
"dyndns.org" "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]" "good|nochg" "dyndns.org" "http://[USERNAME]:[PASSWORD]@members.dyndns.org/nic/update?hostname=[DOMAIN]&myip=[IP]" "good|nochg"
"dynu.com" "http://api.dynu.com/nic/update?hostname=[DOMAIN]&myipv6=[IP]&username=[USERNAME]&password=[PASSWORD]"
"dynu.com" "http://api.dynu.com/nic/update?hostname=[DOMAIN]&myipv6=[IP]&username=[USERNAME]&password=[PASSWORD]"
"dynv6.com" "http://dynv6.com/api/update?hostname=[DOMAIN]&token=[PASSWORD]&ipv6=[IP]" "updated|unchanged" "dynv6.com" "http://dynv6.com/api/update?hostname=[DOMAIN]&token=[PASSWORD]&ipv6=[IP]" "updated|unchanged"


+ 14
- 7
net/ddns-scripts/files/update_cloudflare_com_v4.sh View File

@ -5,15 +5,16 @@
# script for sending updates to cloudflare.com # script for sending updates to cloudflare.com
#.based on Ben Kulbertis cloudflare-update-record.sh found at http://gist.github.com/benkulbertis #.based on Ben Kulbertis cloudflare-update-record.sh found at http://gist.github.com/benkulbertis
#.and on George Johnson's cf-ddns.sh found at https://github.com/gstuartj/cf-ddns.sh #.and on George Johnson's cf-ddns.sh found at https://github.com/gstuartj/cf-ddns.sh
#.2016-2017 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
#.2016-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
# CloudFlare API documentation at https://api.cloudflare.com/ # CloudFlare API documentation at https://api.cloudflare.com/
# #
# This script is parsed by dynamic_dns_functions.sh inside send_update() function # This script is parsed by dynamic_dns_functions.sh inside send_update() function
# #
# using following options from /etc/config/ddns # 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 - "hostname@yourdomain.TLD" # syntax changed to remove split_FQDN() function and tld_names.dat.gz
# option username - your cloudflare e-mail
# option password - cloudflare api key, you can get it from cloudflare.com/my-account/
# option domain - "hostname@yourdomain.TLD" # syntax changed to remove split_FQDN() function and tld_names.dat.gz
# option param_opt - Whether the record is receiving the performance and security benefits of Cloudflare (not empty => false)
# #
# variable __IP already defined with the ip-address to use for update # variable __IP already defined with the ip-address to use for update
# #
@ -25,7 +26,7 @@
[ $use_https -eq 0 ] && use_https=1 # force HTTPS [ $use_https -eq 0 ] && use_https=1 # force HTTPS
# used variables # used variables
local __HOST __DOMAIN __TYPE __URLBASE __PRGBASE __RUNPROG __DATA __IPV6 __ZONEID __RECID
local __HOST __DOMAIN __TYPE __URLBASE __PRGBASE __RUNPROG __DATA __IPV6 __ZONEID __RECID __PROXIED
local __URLBASE="https://api.cloudflare.com/client/v4" local __URLBASE="https://api.cloudflare.com/client/v4"
# split __HOST __DOMAIN from $domain # split __HOST __DOMAIN from $domain
@ -174,10 +175,16 @@ __DATA=$(grep -o '"content":"[^"]*' $DATFILE | grep -o '[^"]*$' | head -1)
} }
# update is needed # update is needed
# let's build data to send,
# let's build data to send
# set proxied parameter (default "true")
[ -z "$param_opt" ] && __PROXIED="true" || {
__PROXIED="false"
write_log 7 "Cloudflare 'proxied' disabled"
}
# use file to work around " needed for json # use file to work around " needed for json
cat > $DATFILE << EOF cat > $DATFILE << EOF
{"id":"$__ZONEID","type":"$__TYPE","name":"$__HOST","content":"$__IP"}
{"id":"$__ZONEID","type":"$__TYPE","name":"$__HOST","content":"$__IP","proxied":$__PROXIED}
EOF EOF
# let's complete transfer command # let's complete transfer command


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

@ -4,7 +4,7 @@
# #
# script for sending updates to godaddy.com # script for sending updates to godaddy.com
#.based on GoDaddy.sh v1.0 by Nazar78 @ TeaNazaR.com #.based on GoDaddy.sh v1.0 by Nazar78 @ TeaNazaR.com
#.2017 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
#.2017-2018 Christian Schoenebeck <christian dot schoenebeck at gmail dot com>
# GoDaddy Documentation at https://developer.godaddy.com/doc # GoDaddy Documentation at https://developer.godaddy.com/doc
# #
# This script is parsed by dynamic_dns_functions.sh inside send_update() function # This script is parsed by dynamic_dns_functions.sh inside send_update() function
@ -85,6 +85,7 @@ godaddy_transfer() {
write_log 7 "$(cat $DATFILE)" write_log 7 "$(cat $DATFILE)"
return 1 return 1
} }
return 0
} }
# Build base command to use # Build base command to use


Loading…
Cancel
Save