|
|
@@ -65,7 +65,7 @@ _response=
|
|
|
|
_statusHostname=
|
|
|
|
_statusHostname=
|
|
|
|
_statusUsername=
|
|
|
|
_statusUsername=
|
|
|
|
_statusPassword=
|
|
|
|
_statusPassword=
|
|
|
|
_version=0.1.2
|
|
|
|
_version=0.1.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
|
|
|
@@ -345,22 +345,13 @@ function debugMode() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function infoMessage() {
|
|
|
|
|
|
|
|
echo "$(logtime) INFO: $*"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function debugMessage() {
|
|
|
|
function debugMessage() {
|
|
|
|
if debugMode; then
|
|
|
|
if debugMode; then
|
|
|
|
echo "$(logtime) DEBUG: $*"
|
|
|
|
echo "Debug: $*"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function errorMessage() { printf "$(logtime) ERROR: %s\n" "$*" >&2; }
|
|
|
|
function echoerr() { printf "%s\n" "$*" >&2; }
|
|
|
|
|
|
|
|
|
|
|
|
function logtime() {
|
|
|
|
|
|
|
|
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
|
|
|
|
|
|
|
echo "[$LOGTIME]"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# The main domain as an identifier for the dns zone is required for the updateRecord call
|
|
|
|
# The main domain as an identifier for the dns zone is required for the updateRecord call
|
|
|
|
function getMainDomain() {
|
|
|
|
function getMainDomain() {
|
|
|
@@ -482,7 +473,7 @@ function dynupdate() {
|
|
|
|
myipv6_str=ipv6
|
|
|
|
myipv6_str=ipv6
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
* )
|
|
|
|
errorMessage "$DYNB_SERVICE_PROVIDER is not supported"
|
|
|
|
echoerr "$DYNB_SERVICE_PROVIDER is not supported"
|
|
|
|
exit 1
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
esac
|
|
|
@@ -525,64 +516,64 @@ function dynupdate() {
|
|
|
|
case $_response in
|
|
|
|
case $_response in
|
|
|
|
good* | OK* | "addresses updated" )
|
|
|
|
good* | OK* | "addresses updated" )
|
|
|
|
if [[ $_response == "good 127.0.0.1" ]]; then
|
|
|
|
if [[ $_response == "good 127.0.0.1" ]]; then
|
|
|
|
errorMessage "$_response: Request ignored."
|
|
|
|
echoerr "Error: $_response: Request ignored."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
else
|
|
|
|
infoMessage "$_response: The DynDNS update has been executed."
|
|
|
|
echo "$_response: The DynDNS update has been executed."
|
|
|
|
_errorCounter=0
|
|
|
|
_errorCounter=0
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
nochg* )
|
|
|
|
nochg* )
|
|
|
|
infoMessage "$_response: Nothing has changed, IP addresses are still up to date."
|
|
|
|
echo "$_response: Nothing has changed, IP addresses are still up to date."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
abuse )
|
|
|
|
abuse )
|
|
|
|
errorMessage "$_response: Username is blocked due to abuse."
|
|
|
|
echoerr "Error: $_response: Username is blocked due to abuse."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
badauth | 401 )
|
|
|
|
badauth | 401 )
|
|
|
|
errorMessage "$_response: Invalid username password combination."
|
|
|
|
echoerr "Error: $_response: Invalid username password combination."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
badagent )
|
|
|
|
badagent )
|
|
|
|
errorMessage "$_response: Client disabled. Something is very wrong!"
|
|
|
|
echoerr "Error: $_response: Client disabled. Something is very wrong!"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
!donator )
|
|
|
|
!donator )
|
|
|
|
errorMessage "$_response: An update request was sent, including a feature that is not available to that particular user such as offline options."
|
|
|
|
echoerr "Error: $_response: An update request was sent, including a feature that is not available to that particular user such as offline options."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
!yours )
|
|
|
|
!yours )
|
|
|
|
errorMessage "$_response: The domain does not belong to your user account"
|
|
|
|
echoerr "Error: $_response: The domain does not belong to your user account"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
notfqdn )
|
|
|
|
notfqdn )
|
|
|
|
errorMessage "$_response: Hostname $DYNB_DYN_DOMAIN is invalid"
|
|
|
|
echoerr "Error: $_response: Hostname $DYNB_DYN_DOMAIN is invalid"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
nohost )
|
|
|
|
nohost )
|
|
|
|
errorMessage "$_response: Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
|
|
|
echoerr "Error: $_response: Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
numhost )
|
|
|
|
numhost )
|
|
|
|
errorMessage "$_response: Too many hostnames have been specified for this update"
|
|
|
|
echoerr "Error: $_response: Too many hostnames have been specified for this update"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
dnserr )
|
|
|
|
dnserr )
|
|
|
|
errorMessage "$_response: There is an internal error in the dyndns update system. Retry update no sooner than 30 minutes."
|
|
|
|
echoerr "Error: $_response: There is an internal error in the dyndns update system. Retry update no sooner than 30 minutes."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
911 | 5* )
|
|
|
|
911 | 5* )
|
|
|
|
errorMessage "$_response: A fatal error on provider side such as a database outage. Retry update no sooner than 30 minutes."
|
|
|
|
echoerr "Error: $_response: A fatal error on provider side such as a database outage. Retry update no sooner than 30 minutes."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
* )
|
|
|
|
if [[ "$_response" == "$_status" ]]; then
|
|
|
|
if [[ "$_response" == "$_status" ]]; then
|
|
|
|
errorMessage "An unknown response code has been received. $_response"
|
|
|
|
echoerr "Error: An unknown response code has been received. $_response"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
else
|
|
|
|
errorMessage "unknown respnse code: $_response"
|
|
|
|
echoerr "Error: unknown respnse code: $_response"
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
;;
|
|
|
@@ -598,14 +589,14 @@ function checkStatus() {
|
|
|
|
case $_status in
|
|
|
|
case $_status in
|
|
|
|
nochg* )
|
|
|
|
nochg* )
|
|
|
|
if [[ _errorCounter -gt 1 ]]; then
|
|
|
|
if [[ _errorCounter -gt 1 ]]; then
|
|
|
|
errorMessage "The update client was spamming unnecessary update requests, something might be wrong with your IP-Check site."
|
|
|
|
echoerr "Error: The update client was spamming unnecessary update requests, something might be wrong with your IP-Check site."
|
|
|
|
errorMessage "Fix your config an then delete $_statusFile or restart your docker container"
|
|
|
|
echoerr "Fix your config an then delete $_statusFile"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
nohost | !yours )
|
|
|
|
nohost | !yours )
|
|
|
|
if [[ "$_statusHostname" == "$DYNB_DYN_DOMAIN" && ( "$_statusUsername" == "$DYNB_USERNAME" || $_statusUsername == "$DYNB_TOKEN" ) ]]; then
|
|
|
|
if [[ "$_statusHostname" == "$DYNB_DYN_DOMAIN" && ( "$_statusUsername" == "$DYNB_USERNAME" || $_statusUsername == "$DYNB_TOKEN" ) ]]; then
|
|
|
|
errorMessage "Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
|
|
|
echoerr "Error: Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
else
|
|
|
|
rm "$_statusFile"
|
|
|
|
rm "$_statusFile"
|
|
|
@@ -614,7 +605,7 @@ function checkStatus() {
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
badauth | 401 )
|
|
|
|
badauth | 401 )
|
|
|
|
if [[ "$_statusUsername" == "$DYNB_USERNAME" && "$_statusPassword" == "$DYNB_PASSWORD" ]]; then
|
|
|
|
if [[ "$_statusUsername" == "$DYNB_USERNAME" && "$_statusPassword" == "$DYNB_PASSWORD" ]]; then
|
|
|
|
errorMessage "Invalid username password combination."
|
|
|
|
echoerr "Error: Invalid username password combination."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
else
|
|
|
|
rm "$_statusFile"
|
|
|
|
rm "$_statusFile"
|
|
|
@@ -622,19 +613,19 @@ function checkStatus() {
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
badagent )
|
|
|
|
badagent )
|
|
|
|
errorMessage "Client is deactivated by provider."
|
|
|
|
echoerr "Error: Client is deactivated by provider."
|
|
|
|
echo "Fix your config and then manually remove $_statusFile to reset the client blockade."
|
|
|
|
echo "Fix your config and then manually remove $_statusFile to reset the client blockade."
|
|
|
|
echo "If it still fails file an issue at github or try another client :)"
|
|
|
|
echo "If it still fails file an issue at github or try another client :)"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
!donator )
|
|
|
|
!donator )
|
|
|
|
errorMessage "An update request was sent, including a feature that is not available to that particular user such as offline options."
|
|
|
|
echoerr "Error: An update request was sent, including a feature that is not available to that particular user such as offline options."
|
|
|
|
echo "Fix your config and then manually remove $_statusFile to reset the client blockade"
|
|
|
|
echo "Fix your config and then manually remove $_statusFile to reset the client blockade"
|
|
|
|
echo "If it still fails file an issue at github or try another client :)"
|
|
|
|
echo "If it still fails file an issue at github or try another client :)"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
abuse )
|
|
|
|
abuse )
|
|
|
|
errorMessage "Username is blocked due to abuse."
|
|
|
|
echoerr "Error: Username is blocked due to abuse."
|
|
|
|
echo "Fix your config and then manually remove $_statusFile to reset the client blockade"
|
|
|
|
echo "Fix your config and then manually remove $_statusFile to reset the client blockade"
|
|
|
|
echo "If it still fails file an issue at github or try another client :)"
|
|
|
|
echo "If it still fails file an issue at github or try another client :)"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
@@ -642,7 +633,7 @@ function checkStatus() {
|
|
|
|
911 | 5* )
|
|
|
|
911 | 5* )
|
|
|
|
delta=$(( $(date +%s) - _eventTime ))
|
|
|
|
delta=$(( $(date +%s) - _eventTime ))
|
|
|
|
if [[ $delta -lt 1800 ]]; then
|
|
|
|
if [[ $delta -lt 1800 ]]; then
|
|
|
|
errorMessage "$_status: The provider currently has an fatal error. DynB will wait for next update until 30 minutes have passed since last request, $(date --date=@$delta -u +%M) minutes already passed."
|
|
|
|
echoerr "$_status: The provider currently has an fatal error. DynB will wait for next update until 30 minutes have passed since last request, $(date --date=@$delta -u +%M) minutes already passed."
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
else
|
|
|
|
rm "$_statusFile"
|
|
|
|
rm "$_statusFile"
|
|
|
@@ -651,7 +642,7 @@ function checkStatus() {
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
* )
|
|
|
|
if [[ _errorCounter -gt 1 ]]; then
|
|
|
|
if [[ _errorCounter -gt 1 ]]; then
|
|
|
|
errorMessage "An unknown response code has repeatedly been received. $_response"
|
|
|
|
echoerr "Error: An unknown response code has repeatedly been received. $_response"
|
|
|
|
return 1
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
@@ -665,18 +656,18 @@ function checkStatus() {
|
|
|
|
function ipHasChanged() {
|
|
|
|
function ipHasChanged() {
|
|
|
|
if [[ ${1} == 4 ]]; then
|
|
|
|
if [[ ${1} == 4 ]]; then
|
|
|
|
remote_ip=$(getRemoteIP 4 $_ipv4_checker)
|
|
|
|
remote_ip=$(getRemoteIP 4 $_ipv4_checker)
|
|
|
|
#TODO: this is duplicated code, refactor this.
|
|
|
|
#TODO: this is doublicated code, refactor this some time
|
|
|
|
if [[ $? -gt 0 ]]; then
|
|
|
|
if [[ $? -gt 0 ]]; then
|
|
|
|
errorMessage "IPCheck (getRemoteIP 4) request failed $remote_ip"
|
|
|
|
echoerr "IPCheck (getRemoteIP) request failed $remote_ip"
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ $DYNB_UPDATE_METHOD == domrobot ]]; then
|
|
|
|
if [[ $DYNB_UPDATE_METHOD == domrobot ]]; then
|
|
|
|
dns_ip=$(getDNSIP A)
|
|
|
|
dns_ip=$(getDNSIP A)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
dig_response=$(dig @${_DNS_checkServer} in a +short "$DYNB_DYN_DOMAIN")
|
|
|
|
dig_response=$(dig @${_DNS_checkServer} in a +short "$DYNB_DYN_DOMAIN")
|
|
|
|
#TODO: this is duplicated code, refactor this.
|
|
|
|
#TODO: this is doublicated code, refactor this some time
|
|
|
|
if [[ $dig_response == ";; connection timed out; no servers could be reached" ]]; then
|
|
|
|
if [[ $dig_response == ";; connection timed out; no servers could be reached" ]]; then
|
|
|
|
errorMessage "DNS request failed $dig_response"
|
|
|
|
echoerr "DNS request failed $dig_response"
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
dns_ip=$dig_response
|
|
|
|
dns_ip=$dig_response
|
|
|
@@ -684,18 +675,18 @@ function ipHasChanged() {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ ${1} == 6 ]]; then
|
|
|
|
if [[ ${1} == 6 ]]; then
|
|
|
|
remote_ip=$(getRemoteIP 6 $_ipv6_checker)
|
|
|
|
remote_ip=$(getRemoteIP 6 $_ipv6_checker)
|
|
|
|
#TODO: this is duplicated code, refactor this.
|
|
|
|
#TODO: this is doublicated code, refactor this some time
|
|
|
|
if [[ $? -gt 0 ]]; then
|
|
|
|
if [[ $? -gt 0 ]]; then
|
|
|
|
errorMessage "IPCheck (getRemoteIP 6) request failed $remote_ip"
|
|
|
|
echoerr "IPCheck (getRemoteIP) request failed $remote_ip"
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ $DYNB_UPDATE_METHOD == domrobot ]]; then
|
|
|
|
if [[ $DYNB_UPDATE_METHOD == domrobot ]]; then
|
|
|
|
dns_ip=$(getDNSIP AAAA)
|
|
|
|
dns_ip=$(getDNSIP AAAA)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
dig_response=$(dig @${_DNS_checkServer} in aaaa +short "$DYNB_DYN_DOMAIN")
|
|
|
|
dig_response=$(dig @${_DNS_checkServer} in aaaa +short "$DYNB_DYN_DOMAIN")
|
|
|
|
#TODO: this is duplicated code, refactor this.
|
|
|
|
#TODO: this is doublicated code, refactor this some time
|
|
|
|
if [[ $dig_response == ";; connection timed out; no servers could be reached" ]]; then
|
|
|
|
if [[ $dig_response == ";; connection timed out; no servers could be reached" ]]; then
|
|
|
|
errorMessage "DNS request failed $dig_response"
|
|
|
|
echoerr "DNS request failed $dig_response"
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
dns_ip=$dig_response
|
|
|
|
dns_ip=$dig_response
|
|
|
@@ -788,15 +779,6 @@ function handleParameters() {
|
|
|
|
if [[ $DYNB_DEBUG == true ]]; then
|
|
|
|
if [[ $DYNB_DEBUG == true ]]; then
|
|
|
|
_debug=1
|
|
|
|
_debug=1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ -n $DYNB_IPv4_CHECK_SITE ]]; then
|
|
|
|
|
|
|
|
_ipv4_checker=$DYNB_IPv4_CHECK_SITE
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $DYNB_IPv6_CHECK_SITE ]]; then
|
|
|
|
|
|
|
|
_ipv6_checker=$DYNB_IPv6_CHECK_SITE
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $DYNB_DNS_CHECK_SERVER ]]; then
|
|
|
|
|
|
|
|
_DNS_checkServer=$DYNB_DNS_CHECK_SERVER
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -805,31 +787,30 @@ function handleParameters() {
|
|
|
|
##################
|
|
|
|
##################
|
|
|
|
|
|
|
|
|
|
|
|
function checkDependencies() {
|
|
|
|
function checkDependencies() {
|
|
|
|
failCounter=0
|
|
|
|
## If there will be more general dependencies use a loop
|
|
|
|
for i in curl dig; do
|
|
|
|
# for i in curl and some other stuff; do
|
|
|
|
if ! command -v $i >/dev/null 2>&1; then
|
|
|
|
# if ! command -v $i >/dev/null 2>&1; then
|
|
|
|
errorMessage "could not find \"$i\", DynB depends on it. "
|
|
|
|
# echoerr "Error: could not find \"$i\", DynB depends on it. "
|
|
|
|
(( failCounter++ ))
|
|
|
|
# exit 1
|
|
|
|
fi
|
|
|
|
# fi
|
|
|
|
done
|
|
|
|
# done
|
|
|
|
[[ -x $(command -v jq 2> /dev/null) ]] || {
|
|
|
|
[[ -x $(command -v jq 2> /dev/null) ]] || {
|
|
|
|
if [[ $DYNB_UPDATE_METHOD != dyndns* ]]; then
|
|
|
|
if [[ $DYNB_UPDATE_METHOD != dyndns* ]]; then
|
|
|
|
echo "This script depends on jq and it is not available." >&2
|
|
|
|
echo "This script depends on jq and it is not available." >&2
|
|
|
|
(( failCounter++ ))
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if [[ failCounter -gt 0 ]]; then
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function doUnsets() {
|
|
|
|
function doUnsets() {
|
|
|
|
unset _network_interface
|
|
|
|
unset _network_interface
|
|
|
|
unset _DNS_checkServer
|
|
|
|
unset _DNS_checkServer
|
|
|
|
unset _dns_records
|
|
|
|
unset _dns_records
|
|
|
|
|
|
|
|
unset DYNB_DYN_DOMAIN
|
|
|
|
unset _has_getopt
|
|
|
|
unset _has_getopt
|
|
|
|
unset _help_message
|
|
|
|
unset _help_message
|
|
|
|
unset _INWX_JSON_API_URL
|
|
|
|
unset _INWX_JSON_API_URL
|
|
|
|
|
|
|
|
unset DYNB_IP_MODE
|
|
|
|
unset _ipv4_checker
|
|
|
|
unset _ipv4_checker
|
|
|
|
unset _ipv6_checker
|
|
|
|
unset _ipv6_checker
|
|
|
|
unset _is_IPv4_enabled
|
|
|
|
unset _is_IPv4_enabled
|
|
|
@@ -837,75 +818,59 @@ function doUnsets() {
|
|
|
|
unset _main_domain
|
|
|
|
unset _main_domain
|
|
|
|
unset _new_IPv4
|
|
|
|
unset _new_IPv4
|
|
|
|
unset _new_IPv6
|
|
|
|
unset _new_IPv6
|
|
|
|
unset _version
|
|
|
|
|
|
|
|
unset DYNB_DYN_DOMAIN
|
|
|
|
|
|
|
|
unset DYNB_USERNAME
|
|
|
|
|
|
|
|
unset DYNB_PASSWORD
|
|
|
|
unset DYNB_PASSWORD
|
|
|
|
unset DYNB_TOKEN
|
|
|
|
unset DYNB_USERNAME
|
|
|
|
unset DYNB_SERVICE_PROVIDER
|
|
|
|
unset DYNB_SERVICE_PROVIDER
|
|
|
|
unset DYNB_IP_MODE
|
|
|
|
unset _version
|
|
|
|
unset DYNB_INTERVAL
|
|
|
|
|
|
|
|
unset DYNB_IPv4_CHECK_SITE
|
|
|
|
|
|
|
|
unset DYNB_IPv6_CHECK_SITE
|
|
|
|
|
|
|
|
unset DYNB_DNS_CHECK_SERVER
|
|
|
|
|
|
|
|
unset DYNB_DEBUG
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function doDomrobotUpdates() {
|
|
|
|
|
|
|
|
getMainDomain
|
|
|
|
|
|
|
|
fetchDNSRecords
|
|
|
|
|
|
|
|
if [[ $_is_IPv4_enabled == true ]]; then
|
|
|
|
|
|
|
|
ipHasChanged 4
|
|
|
|
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
|
|
|
|
updateRecord 4
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Skip IPv4 record update, it is already up to date"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $_is_IPv6_enabled == true ]]; then
|
|
|
|
|
|
|
|
ipHasChanged 6
|
|
|
|
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
|
|
|
|
updateRecord 6
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Skip IPv6 record update, it is already up to date"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function doDynDNS2Updates() {
|
|
|
|
|
|
|
|
changed=0
|
|
|
|
|
|
|
|
if [[ $_is_IPv4_enabled == true ]]; then
|
|
|
|
|
|
|
|
ipHasChanged 4
|
|
|
|
|
|
|
|
(( changed += $? ))
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $_is_IPv6_enabled == true ]]; then
|
|
|
|
|
|
|
|
ipHasChanged 6
|
|
|
|
|
|
|
|
(( changed += $? ))
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $changed -gt 0 ]]; then
|
|
|
|
|
|
|
|
if checkStatus; then
|
|
|
|
|
|
|
|
debugMessage "checkStatus has no errors, try update"
|
|
|
|
|
|
|
|
if dynupdate; then
|
|
|
|
|
|
|
|
debugMessage "DynDNS2 update success"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Save new status after dynupdate has failed"
|
|
|
|
|
|
|
|
setStatus "$_response" "$(date +%s)" $(( _errorCounter += 1 )) "$DYNB_DYN_DOMAIN" "${DYNB_USERNAME}" "${DYNB_PASSWORD}${DYNB_TOKEN}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Skip DynDNS2 update, IPs are up to date or there is a connection problem"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function doUpdates() {
|
|
|
|
function doUpdates() {
|
|
|
|
if [[ $DYNB_UPDATE_METHOD == "domrobot" ]]; then
|
|
|
|
if [[ $DYNB_UPDATE_METHOD == "domrobot" ]]; then
|
|
|
|
doDomrobotUpdates
|
|
|
|
getMainDomain
|
|
|
|
|
|
|
|
fetchDNSRecords
|
|
|
|
|
|
|
|
if [[ $_is_IPv4_enabled == true ]]; then
|
|
|
|
|
|
|
|
ipHasChanged 4
|
|
|
|
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
|
|
|
|
updateRecord 4
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Skip IPv4 record update, it is already up to date"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $_is_IPv6_enabled == true ]]; then
|
|
|
|
|
|
|
|
ipHasChanged 6
|
|
|
|
|
|
|
|
if [[ $? == 1 ]]; then
|
|
|
|
|
|
|
|
updateRecord 6
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Skip IPv6 record update, it is already up to date"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [[ $DYNB_UPDATE_METHOD == "dyndns" ]]; then
|
|
|
|
if [[ $DYNB_UPDATE_METHOD == "dyndns" ]]; then
|
|
|
|
doDynDNS2Updates
|
|
|
|
changed=0
|
|
|
|
|
|
|
|
if [[ $_is_IPv4_enabled == true ]]; then
|
|
|
|
|
|
|
|
ipHasChanged 4
|
|
|
|
|
|
|
|
(( changed += $? ))
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $_is_IPv6_enabled == true ]]; then
|
|
|
|
|
|
|
|
ipHasChanged 6
|
|
|
|
|
|
|
|
(( changed += $? ))
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $changed -gt 0 ]]; then
|
|
|
|
|
|
|
|
if checkStatus; then
|
|
|
|
|
|
|
|
debugMessage "checkStatus has no errors, try update"
|
|
|
|
|
|
|
|
if dynupdate; then
|
|
|
|
|
|
|
|
debugMessage "DynDNS2 update success"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Save new status after dynupdate has failed"
|
|
|
|
|
|
|
|
setStatus "$_response" "$(date +%s)" $(( _errorCounter += 1 )) "$DYNB_DYN_DOMAIN" "${DYNB_USERNAME}" "${DYNB_PASSWORD}${DYNB_TOKEN}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Skip DynDNS2 update, checkStatus fetched previous error."
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
debugMessage "Skip DynDNS2 update, IPs are up to date or there is a connection problem"
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@@ -935,6 +900,9 @@ function dynb() {
|
|
|
|
|
|
|
|
|
|
|
|
handleParameters
|
|
|
|
handleParameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## execute operations
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if loopMode; then
|
|
|
|
if loopMode; then
|
|
|
|
while :
|
|
|
|
while :
|
|
|
|
do
|
|
|
|
do
|
|
|
|