mirror of
https://github.com/EV21/dynb.git
synced 2025-12-26 16:39:32 +01:00
Compare commits
2 Commits
ab330e9731
...
642e53aadf
| Author | SHA1 | Date | |
|---|---|---|---|
|
642e53aadf
|
|||
|
b8565eb38f
|
@@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
### 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 completion. [Eduard Veit]
|
* :sparkles: add completion. [Eduard Veit]
|
||||||
|
|
||||||
:sparkles: add man page
|
:sparkles: add man page
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ The following update methods are currently implemented:
|
|||||||
### DynDNS2
|
### DynDNS2
|
||||||
|
|
||||||
* INWX.com
|
* INWX.com
|
||||||
* dynv6.com
|
* deSEC.io (dedyn.io)
|
||||||
|
* DuckDNS.org
|
||||||
|
* dynv6.com
|
||||||
|
|
||||||
## 📦 Requirements
|
## 📦 Requirements
|
||||||
|
|
||||||
|
|||||||
83
dynb.sh
83
dynb.sh
@@ -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
|
||||||
@@ -69,7 +69,7 @@ _version=0.0.1
|
|||||||
_userAgent="DynB/$_version github.com/EV21/dynb"
|
_userAgent="DynB/$_version github.com/EV21/dynb"
|
||||||
_configFile=$HOME/.local/share/dynb/.env
|
_configFile=$HOME/.local/share/dynb/.env
|
||||||
_statusFile=/tmp/dynb.status
|
_statusFile=/tmp/dynb.status
|
||||||
_debug=1
|
_debug=0
|
||||||
|
|
||||||
# Created by argbash-init v2.10.0
|
# Created by argbash-init v2.10.0
|
||||||
# Rearrange the order of options below according to what you would like to see in the help message.
|
# Rearrange the order of options below according to what you would like to see in the help message.
|
||||||
@@ -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
|
||||||
|
|
||||||
@@ -325,7 +326,7 @@ function debugMode() {
|
|||||||
|
|
||||||
function debugMessage() {
|
function debugMessage() {
|
||||||
if debugMode; then
|
if debugMode; then
|
||||||
echo "Debug: ${1}"
|
echo "Debug: $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,17 +430,34 @@ function dynupdate() {
|
|||||||
myipv6_str=myipv6
|
myipv6_str=myipv6
|
||||||
|
|
||||||
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/?"
|
||||||
|
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&"
|
||||||
|
|
||||||
if [[ $_serviceProvider == "inwx" ]]; then
|
case $_serviceProvider in
|
||||||
dyndns_update_url=$INWX_DYNDNS_UPDATE_URL
|
inwx* | INWX* )
|
||||||
fi
|
dyndns_update_url=$INWX_DYNDNS_UPDATE_URL
|
||||||
if [[ $_serviceProvider == "dynv6" ]]; then
|
;;
|
||||||
dyndns_update_url="${DYNV6_DYNDNS_UPDATE_URL}"
|
deSEC* | desec* | dedyn* )
|
||||||
myip_str=ipv4
|
dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}"
|
||||||
myipv6_str=ipv6
|
;;
|
||||||
fi
|
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
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# pre encode ip parameters
|
||||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]]; then
|
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]]; then
|
||||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}&${myipv6_str}=${_new_IPv6}"
|
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}&${myipv6_str}=${_new_IPv6}"
|
||||||
fi
|
fi
|
||||||
@@ -450,22 +468,32 @@ function dynupdate() {
|
|||||||
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
|
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
|
||||||
fi
|
fi
|
||||||
debugMessage "Update URL was: $dyndns_update_url"
|
debugMessage "Update URL was: $dyndns_update_url"
|
||||||
|
|
||||||
## request ##
|
## request ##
|
||||||
if [[ $_serviceProvider == "dynv6" ]]; then
|
case $_serviceProvider in
|
||||||
_response=$(curl --silent "$_interface_str" \
|
inwx* | INWX* )
|
||||||
--user-agent "$_userAgent" \
|
_response=$(curl --silent "$_interface_str" \
|
||||||
"${dyndns_update_url}"
|
|
||||||
)
|
|
||||||
fi
|
|
||||||
if [[ $_serviceProvider == "inwx" ]]; then
|
|
||||||
_response=$(curl --silent "$_interface_str" \
|
|
||||||
--user-agent "$_userAgent" \
|
--user-agent "$_userAgent" \
|
||||||
--user "$_username":"$_password" \
|
--user "$_username":"$_password" \
|
||||||
"${dyndns_update_url}" )
|
"${dyndns_update_url}" )
|
||||||
fi
|
;;
|
||||||
|
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* | duckDNS* | duckdns* )
|
||||||
|
_response=$(curl --silent "$_interface_str" \
|
||||||
|
--user-agent "$_userAgent" \
|
||||||
|
"${dyndns_update_url}"
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
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
|
||||||
@@ -624,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
|
||||||
@@ -653,6 +681,9 @@ function handleParameters() {
|
|||||||
if [[ $_arg_reset == "on" ]]; then
|
if [[ $_arg_reset == "on" ]]; then
|
||||||
rm --verbose "$_statusFile"
|
rm --verbose "$_statusFile"
|
||||||
exit 0
|
exit 0
|
||||||
|
fi
|
||||||
|
if [[ $_arg_debug == "on" ]]; then
|
||||||
|
_debug=1
|
||||||
fi
|
fi
|
||||||
if [[ $_arg_update_method != "" ]]; then
|
if [[ $_arg_update_method != "" ]]; then
|
||||||
_update_method=$_arg_update_method
|
_update_method=$_arg_update_method
|
||||||
@@ -792,16 +823,18 @@ function dynb() {
|
|||||||
fi
|
fi
|
||||||
if [[ $changed -gt 0 ]]; then
|
if [[ $changed -gt 0 ]]; then
|
||||||
if checkStatus; then
|
if checkStatus; then
|
||||||
debugMessage "checkStatus has no errors"
|
debugMessage "checkStatus has no errors, try update"
|
||||||
if dynupdate; then
|
if dynupdate; then
|
||||||
debugMessage "DynDNS2 update success"
|
debugMessage "DynDNS2 update success"
|
||||||
else
|
else
|
||||||
debugMessage "Save new status after dynupdate has failed"
|
debugMessage "Save new status after dynupdate has failed"
|
||||||
setStatus "$_response" "$(date +%s)" $(( _errorCounter += 1 )) "$_dyn_domain" "${_username}${_token}"
|
setStatus "$_response" "$(date +%s)" $(( _errorCounter += 1 )) "$_dyn_domain" "${_username}" "${_password}${_token}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
|
debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
debugMessage "Skip DynDNS2 update, IPs are up to date"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
doUnsets
|
doUnsets
|
||||||
|
|||||||
@@ -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 | 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.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
.. |OPTION_DOMAIN| replace:: dyndns.example.com
|
.. |OPTION_DOMAIN| replace:: dyndns.example.com
|
||||||
|
|
||||||
.. |OPTION_SERVICE_PROVIDER| replace:: inwx | dynv6
|
.. |OPTION_SERVICE_PROVIDER| replace:: deSEC | duckdns | dynv6 | inwx
|
||||||
|
|
||||||
.. |OPTION_USERNAME| replace:: e.g. user42
|
.. |OPTION_USERNAME| replace:: e.g. user42
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user