1
0
mirror of https://github.com/EV21/dynb.git synced 2025-12-26 16:39:32 +01:00

add support for Duck DNS as DynDNS2 provider

This commit is contained in:
2021-04-04 14:39:19 +02:00
parent b8565eb38f
commit 4d28f55ce9
5 changed files with 24 additions and 15 deletions

View File

@@ -5,6 +5,8 @@
### New ### New
* :sparkles: add support for Duck DNS as DynDNS2 provider. [Eduard Veit]
* :sparkles: add support for deSEC as DynDNS2 provider. [Eduard Veit] * :sparkles: add support for deSEC as DynDNS2 provider. [Eduard Veit]
* :sparkles: add completion. [Eduard Veit] * :sparkles: add completion. [Eduard Veit]

View File

@@ -25,8 +25,9 @@ The following update methods are currently implemented:
### DynDNS2 ### DynDNS2
* INWX.com * INWX.com
* dynv6.com
* deSEC.io (dedyn.io) * deSEC.io (dedyn.io)
* DuckDNS.org
* dynv6.com
## 📦 Requirements ## 📦 Requirements
@@ -49,7 +50,6 @@ If you want to add the script to you PATH, run :point_down:
``` ```
bash dynb.sh --link bash dynb.sh --link
``` ```
This convenience function only works if `util-linux` is installed on your system.
## ⚙ Configuration ## ⚙ Configuration

27
dynb.sh
View File

@@ -12,7 +12,7 @@
_dyn_domain= _dyn_domain=
## service provider could be inwx ## service provider could be deSEC, duckdns, dynv6, inwx
_serviceProvider= _serviceProvider=
## update method options: domrobot, dyndns ## update method options: domrobot, dyndns
@@ -287,6 +287,7 @@ parse_commandline "$@"
### END OF CODE GENERATED BY Argbash (sortof) ### ]) ### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash # [ <-- needed because of Argbash
# The generated argbash help message does not look as nice as this:
_help_message="$(cat << 'EOF' _help_message="$(cat << 'EOF'
dynb - dynamic DNS update script for bash dynb - dynamic DNS update script for bash
@@ -430,20 +431,26 @@ function dynupdate() {
INWX_DYNDNS_UPDATE_URL="https://dyndns.inwx.com/nic/update?" INWX_DYNDNS_UPDATE_URL="https://dyndns.inwx.com/nic/update?"
DESEC_DYNDNS_UPDATE_URL="https://update.dedyn.io/?" 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&" DYNV6_DYNDNS_UPDATE_URL="https://dynv6.com/api/update?zone=$_dyn_domain&token=$_token&"
case $_serviceProvider in case $_serviceProvider in
inwx | INWX ) inwx* | INWX* )
dyndns_update_url=$INWX_DYNDNS_UPDATE_URL dyndns_update_url=$INWX_DYNDNS_UPDATE_URL
;; ;;
deSEC | desec* | dedyn* ) deSEC* | desec* | dedyn* )
dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}" dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}"
;; ;;
dynv6 ) dynv6* )
dyndns_update_url="${DYNV6_DYNDNS_UPDATE_URL}" dyndns_update_url="${DYNV6_DYNDNS_UPDATE_URL}"
myip_str=ipv4 myip_str=ipv4
myipv6_str=ipv6 myipv6_str=ipv6
;; ;;
DuckDNS* | duckdns* )
dyndns_update_url="${DUCKDNS_DYNDNS_UPDATE_URL}"
myip_str=ipv4
myipv6_str=ipv6
;;
* ) * )
echoerr "$_serviceProvider is not supported" echoerr "$_serviceProvider is not supported"
exit 1 exit 1
@@ -464,20 +471,20 @@ function dynupdate() {
## request ## ## request ##
case $_serviceProvider in case $_serviceProvider in
inwx | INWX ) inwx* | INWX* )
_response=$(curl --silent "$_interface_str" \ _response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \ --user-agent "$_userAgent" \
--user "$_username":"$_password" \ --user "$_username":"$_password" \
"${dyndns_update_url}" ) "${dyndns_update_url}" )
;; ;;
deSEC | desec* | dedyn* ) deSEC* | desec* | dedyn* )
_response=$(curl --silent "$_interface_str" \ _response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \ --user-agent "$_userAgent" \
--header "Authorization: Token $_token" \ --header "Authorization: Token $_token" \
--get --data-urlencode "hostname=$_dyn_domain" \ --get --data-urlencode "hostname=$_dyn_domain" \
"${dyndns_update_url}" ) "${dyndns_update_url}" )
;; ;;
dynv6 ) dynv6* | duckDNS* | duckdns* )
_response=$(curl --silent "$_interface_str" \ _response=$(curl --silent "$_interface_str" \
--user-agent "$_userAgent" \ --user-agent "$_userAgent" \
"${dyndns_update_url}" "${dyndns_update_url}"
@@ -486,7 +493,7 @@ function dynupdate() {
esac esac
case $_response in case $_response in
good* ) good* | OK* )
if [[ $_response == "good 127.0.0.1" ]]; then if [[ $_response == "good 127.0.0.1" ]]; then
echoerr "Error: $_response: Request ignored." echoerr "Error: $_response: Request ignored."
return 1 return 1
@@ -645,10 +652,10 @@ function ipHasChanged() {
if [[ ${1} == 4 ]]; then if [[ ${1} == 4 ]]; then
_new_IPv4=$remote_ip _new_IPv4=$remote_ip
#echo "New IPv4: $_new_IPv4 old was: $dns_ip" debugMessage "New IPv4: $_new_IPv4 old was: $dns_ip"
else else
_new_IPv6=$remote_ip _new_IPv6=$remote_ip
#echo "New IPv6: $_new_IPv6 old was: $dns_ip" debugMessage "New IPv6: $_new_IPv6 old was: $dns_ip"
fi fi
if [[ "$remote_ip" == "$dns_ip" ]]; then if [[ "$remote_ip" == "$dns_ip" ]]; then

View File

@@ -81,7 +81,7 @@ dyndns.example.com
.BI \-s \ SERVICE\-PROVIDER\fR,\fB \ \-\-service\-provider \ SERVICE\-PROVIDER .BI \-s \ SERVICE\-PROVIDER\fR,\fB \ \-\-service\-provider \ SERVICE\-PROVIDER
set your provider in case you are using DynDNS2. set your provider in case you are using DynDNS2.
.sp .sp
inwx | dynv6 | deSEC deSEC | duckdns | dynv6 | inwx
.TP .TP
.BI \-u \ USERNAME\fR,\fB \ \-\-username \ USERNAME .BI \-u \ USERNAME\fR,\fB \ \-\-username \ USERNAME
depends on your selected update method and your provider. depends on your selected update method and your provider.

View File

@@ -22,7 +22,7 @@
.. |OPTION_DOMAIN| replace:: dyndns.example.com .. |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 .. |OPTION_USERNAME| replace:: e.g. user42