From c85d5eaaee96fc82202f17203fe51379541da9f3 Mon Sep 17 00:00:00 2001 From: Eduard Veit Date: Sun, 4 Apr 2021 14:39:19 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20add=20support=20for=20Duck?= =?UTF-8?q?=20DNS=20as=20DynDNS2=20provider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ README.md | 6 +++--- dynb.sh | 27 +++++++++++++++++---------- man/dynb.1 | 2 +- man/man-defs.rst | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 679d27d..d036562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ ### New +* :sparkles: add support for Duck DNS as DynDNS2 provider. [Eduard Veit] + * :sparkles: add support for deSEC as DynDNS2 provider. [Eduard Veit] * :sparkles: add completion. [Eduard Veit] diff --git a/README.md b/README.md index 71d2caa..309aa42 100644 --- a/README.md +++ b/README.md @@ -25,8 +25,9 @@ The following update methods are currently implemented: ### DynDNS2 * INWX.com -* dynv6.com -* deSEC.io (dedyn.io) +* deSEC.io (dedyn.io) +* DuckDNS.org +* dynv6.com ## 📦 Requirements @@ -49,7 +50,6 @@ If you want to add the script to you PATH, run :point_down: ``` bash dynb.sh --link ``` -This convenience function only works if `util-linux` is installed on your system. ## ⚙ Configuration diff --git a/dynb.sh b/dynb.sh index 7e82fd5..7eaaa8a 100755 --- a/dynb.sh +++ b/dynb.sh @@ -12,7 +12,7 @@ _dyn_domain= -## service provider could be inwx +## service provider could be deSEC, duckdns, dynv6, inwx _serviceProvider= ## update method options: domrobot, dyndns @@ -287,6 +287,7 @@ parse_commandline "$@" ### END OF CODE GENERATED BY Argbash (sortof) ### ]) # [ <-- needed because of Argbash +# The generated argbash help message does not look as nice as this: _help_message="$(cat << 'EOF' dynb - dynamic DNS update script for bash @@ -430,20 +431,26 @@ function dynupdate() { INWX_DYNDNS_UPDATE_URL="https://dyndns.inwx.com/nic/update?" DESEC_DYNDNS_UPDATE_URL="https://update.dedyn.io/?" + DUCKDNS_DYNDNS_UPDATE_URL="https://www.duckdns.org/update?domains=$_dyn_domain&token=$_token&" DYNV6_DYNDNS_UPDATE_URL="https://dynv6.com/api/update?zone=$_dyn_domain&token=$_token&" case $_serviceProvider in - inwx | INWX ) + inwx* | INWX* ) dyndns_update_url=$INWX_DYNDNS_UPDATE_URL ;; - deSEC | desec* | dedyn* ) + deSEC* | desec* | dedyn* ) dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}" ;; - dynv6 ) + dynv6* ) dyndns_update_url="${DYNV6_DYNDNS_UPDATE_URL}" myip_str=ipv4 myipv6_str=ipv6 ;; + DuckDNS* | duckdns* ) + dyndns_update_url="${DUCKDNS_DYNDNS_UPDATE_URL}" + myip_str=ipv4 + myipv6_str=ipv6 + ;; * ) echoerr "$_serviceProvider is not supported" exit 1 @@ -464,20 +471,20 @@ function dynupdate() { ## request ## case $_serviceProvider in - inwx | INWX ) + inwx* | INWX* ) _response=$(curl --silent "$_interface_str" \ --user-agent "$_userAgent" \ --user "$_username":"$_password" \ "${dyndns_update_url}" ) ;; - deSEC | desec* | dedyn* ) + deSEC* | desec* | dedyn* ) _response=$(curl --silent "$_interface_str" \ --user-agent "$_userAgent" \ --header "Authorization: Token $_token" \ --get --data-urlencode "hostname=$_dyn_domain" \ "${dyndns_update_url}" ) ;; - dynv6 ) + dynv6* | duckDNS* | duckdns* ) _response=$(curl --silent "$_interface_str" \ --user-agent "$_userAgent" \ "${dyndns_update_url}" @@ -486,7 +493,7 @@ function dynupdate() { esac case $_response in - good* ) + good* | OK* ) if [[ $_response == "good 127.0.0.1" ]]; then echoerr "Error: $_response: Request ignored." return 1 @@ -645,10 +652,10 @@ function ipHasChanged() { if [[ ${1} == 4 ]]; then _new_IPv4=$remote_ip - #echo "New IPv4: $_new_IPv4 old was: $dns_ip" + debugMessage "New IPv4: $_new_IPv4 old was: $dns_ip" else _new_IPv6=$remote_ip - #echo "New IPv6: $_new_IPv6 old was: $dns_ip" + debugMessage "New IPv6: $_new_IPv6 old was: $dns_ip" fi if [[ "$remote_ip" == "$dns_ip" ]]; then diff --git a/man/dynb.1 b/man/dynb.1 index f9f5e6c..5b47c7c 100644 --- a/man/dynb.1 +++ b/man/dynb.1 @@ -81,7 +81,7 @@ dyndns.example.com .BI \-s \ SERVICE\-PROVIDER\fR,\fB \ \-\-service\-provider \ SERVICE\-PROVIDER set your provider in case you are using DynDNS2. .sp -inwx | dynv6 | deSEC +deSEC | duckdns | dynv6 | inwx .TP .BI \-u \ USERNAME\fR,\fB \ \-\-username \ USERNAME depends on your selected update method and your provider. diff --git a/man/man-defs.rst b/man/man-defs.rst index 565de07..5527bf4 100644 --- a/man/man-defs.rst +++ b/man/man-defs.rst @@ -22,7 +22,7 @@ .. |OPTION_DOMAIN| replace:: dyndns.example.com -.. |OPTION_SERVICE_PROVIDER| replace:: inwx | dynv6 | deSEC +.. |OPTION_SERVICE_PROVIDER| replace:: deSEC | duckdns | dynv6 | inwx .. |OPTION_USERNAME| replace:: e.g. user42