mirror of
https://github.com/EV21/dynb.git
synced 2025-12-26 16:39:32 +01:00
Compare commits
26 Commits
fa60312c0d
...
0.3.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
c83b893fc8
|
|||
|
c9794f7c22
|
|||
|
b8bbce7ec2
|
|||
|
bd6f1336b2
|
|||
|
260bc7172f
|
|||
|
a85b2bf911
|
|||
|
a496acbebf
|
|||
|
c81da8846e
|
|||
|
122e08a42a
|
|||
|
2352d655a3
|
|||
|
341d535f21
|
|||
|
fc2c499daa
|
|||
|
39d5143108
|
|||
|
e58d87cf94
|
|||
|
9d41354695
|
|||
|
d8a298f58a
|
|||
|
3e89610e22
|
|||
|
faa9c371c1
|
|||
|
11fccf2f0e
|
|||
|
75715cb0a8
|
|||
|
6313ee4347
|
|||
|
f37230401f
|
|||
|
d6c98c04ad
|
|||
|
64a5a76b6d
|
|||
|
05120c25e4
|
|||
|
dcb3d7436b
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
.env*
|
||||
docker-compose*
|
||||
.vscode
|
||||
65
CHANGELOG.md
65
CHANGELOG.md
@@ -1,6 +1,71 @@
|
||||
# Changelog
|
||||
|
||||
|
||||
## 0.3.5 (2022-11-03)
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ add support for IPv64.net as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
### Fix
|
||||
|
||||
* Delete status file after success. [Eduard Veit]
|
||||
|
||||
* More status file issues. [Eduard Veit]
|
||||
|
||||
* Incorrect status code handling. [Eduard Veit]
|
||||
|
||||
no persistent status file was written in case of an error as the return status code was always 0
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 change TTL to 60 for IPv64.net. [Eduard Veit]
|
||||
|
||||
* 📝 add IPv64.net as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.3.4 (2022-06-30)
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ add support for ddnss.de as DynDNS2 provider. [Eduard Veit]
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 update providers in README. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.3.3 (2022-06-07)
|
||||
|
||||
### Fix
|
||||
|
||||
* Wrong parameter name for DuckDNS. [Eduard Veit]
|
||||
|
||||
### Documentation
|
||||
|
||||
* 📝 add comments to docker-compose.yml example. [Eduard Veit]
|
||||
|
||||
|
||||
## 0.3.2 (2022-05-26)
|
||||
|
||||
### Features
|
||||
|
||||
* ✨ add tzdata to Dockerfile for timezone config. [Eduard Veit]
|
||||
|
||||
You can now set your timezone with the environment variable
|
||||
`TZ="Europe/Berlin"`
|
||||
|
||||
|
||||
## 0.3.1 (2022-05-26)
|
||||
|
||||
### Fix
|
||||
|
||||
* 🐛 curl/libcurl doesn't support dns-server option. [Eduard Veit]
|
||||
|
||||
the latest alpine we are using for the docker image
|
||||
does also drops the support for that option like debian/ubuntu/etc
|
||||
|
||||
|
||||
## 0.3.0 (2022-05-26)
|
||||
|
||||
### Features
|
||||
|
||||
@@ -7,7 +7,8 @@ apk add \
|
||||
bash \
|
||||
curl \
|
||||
jq \
|
||||
bind-tools
|
||||
bind-tools \
|
||||
tzdata
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
|
||||
57
README.md
57
README.md
@@ -7,8 +7,6 @@ IPv4 (A) and IPv6 (AAAA) record updates are supported.
|
||||
<!-- TOC -->
|
||||
|
||||
- [✨ Update Methods](#-update-methods)
|
||||
- [APIs](#apis)
|
||||
- [DynDNS2](#dyndns2)
|
||||
- [📦 Requirements](#-requirements)
|
||||
- [🚀 Installation](#-installation)
|
||||
- [⚙ Configuration](#-configuration)
|
||||
@@ -25,18 +23,15 @@ IPv4 (A) and IPv6 (AAAA) record updates are supported.
|
||||
|
||||
The following update methods are currently implemented:
|
||||
|
||||
### APIs
|
||||
|
||||
- INWX.com Domrobot JSON-RPC-API\
|
||||
Limitations:
|
||||
- minimum TTL is 300 (5 minutes)
|
||||
|
||||
### DynDNS2
|
||||
|
||||
- INWX.com
|
||||
- deSEC.io (dedyn.io)
|
||||
- DuckDNS.org
|
||||
- dynv6.com
|
||||
| Provider | API | TTL in seconds | Credentials | own domain via NS record | free (sub-) domain |
|
||||
|---------------------|-----------------------|----------------|----------------------------------------------------------------------------------------------|--------------------------|------------------------------------------------|
|
||||
| INWX.com | Domrobot JSON-RPC-API | 300 | customer login `username` & `password`. Mobile TAN (OTP) is currently not supported by DynB. | ✔️ | ⛔ choose one of your owned domains |
|
||||
| INWX.com | DynDNS2 | 60 | specific dyndns `username` & `password` | ✔️ | ⛔ choose one of your owned domains per account |
|
||||
| deSEC.io (dedyn.io) | DynDNS2 | 60 | `token` | ✔️ | ✔️ |
|
||||
| DuckDNS.org | DynDNS2 | 60 | `token` | ⛔ | ✔️ |
|
||||
| dynv6.com | DynDNS2 | 60 | `token` | ✔️ | ✔️ |
|
||||
| ddnss.de | DynDNS2 | 10 | update key as `token` | ⛔ | ✔️ |
|
||||
| IPv64.net | DynDNS2 | 60 | `DynDNS Updatehash` as `token` | ⛔ | ✔️ |
|
||||
|
||||
## 📦 Requirements
|
||||
|
||||
@@ -57,7 +52,7 @@ or simply clone this repo
|
||||
git clone https://github.com/EV21/dynb.git
|
||||
```
|
||||
|
||||
If you want to add the script to you PATH, run :point_down:
|
||||
If you want to add the script to you PATH, run 👇
|
||||
|
||||
```shell
|
||||
bash dynb.sh --link
|
||||
@@ -79,7 +74,7 @@ DYNB_SERVICE_PROVIDER=inwx
|
||||
## update method options: domrobot, dyndns
|
||||
DYNB_UPDATE_METHOD=domrobot
|
||||
|
||||
## ip mode could be either: 4, 6 or dual for dualstack
|
||||
## ip mode could be either: 4, 6 or 64 for dualstack
|
||||
DYNB_IP_MODE=64
|
||||
|
||||
## If you are using the DomRobot RPC-API enter your credentials for the web interface login here
|
||||
@@ -92,14 +87,14 @@ DYNB_TOKEN=
|
||||
|
||||
## 🏃 Run
|
||||
|
||||
If you have a config file just run :point_down:
|
||||
If you have a config file just run 👇
|
||||
|
||||
```bash
|
||||
dynb
|
||||
```
|
||||
|
||||
Alternatively you can use parameters if your system meets the relevant requirements. This example shows the long form parameter, there are also short ones.\
|
||||
Call the help function :point_down:
|
||||
Call the help function 👇
|
||||
|
||||
```bash
|
||||
dynb --help
|
||||
@@ -123,13 +118,13 @@ Just use the parameter `--interval 60` or the environment variable `DYNB_INTERVA
|
||||
|
||||
### crontab
|
||||
|
||||
execute :point_down:
|
||||
execute 👇
|
||||
|
||||
```bash
|
||||
crontab -e
|
||||
```
|
||||
|
||||
then enter :point_down: to run dynb every five minutes.
|
||||
then add the following line 👇 to run dynb every five minutes.
|
||||
|
||||
```bash
|
||||
*/5 * * * * $HOME/.local/bin/dynb >> $HOME/.local/share/dynb/dynb-cron.log
|
||||
@@ -155,25 +150,33 @@ services:
|
||||
image: ev21/dynb
|
||||
container_name: dynb
|
||||
network_mode: host
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
stdin_open: true
|
||||
tty: true
|
||||
environment:
|
||||
- DYNB_DYN_DOMAIN=dyndns.example.com
|
||||
- DYNB_SERVICE_PROVIDER=inwx
|
||||
# Providers: deSec, DuckDNS, dynv6, inwx, ddnss, ipv64
|
||||
- DYNB_SERVICE_PROVIDER=desec
|
||||
# Possible update methods are: dyndns, domrobot
|
||||
- DYNB_UPDATE_METHOD=dyndns
|
||||
# IP modes: 4 (IPv4 only), 6 (IPv6 only), 64 both
|
||||
- DYNB_IP_MODE=64
|
||||
# If your provider uses tokens use DYNB_TOKEN instead of DYNB_USERNAME and DYNB_PASSWORD
|
||||
- DYNB_USERNAME=User42
|
||||
- DYNB_PASSWORD=SuperSecretPassword
|
||||
- DYNB_INTERVAL=60
|
||||
# The interval in seconds is the time the script waits before executing it again
|
||||
- DYNB_INTERVAL=300
|
||||
# TZ: Timezone setting for correct log time
|
||||
- TZ=Europe/Berlin
|
||||
# TERM: For colorful console output (attached mode)
|
||||
- TERM=xterm-256color
|
||||
```
|
||||
|
||||
## environment variables
|
||||
|
||||
| variable | default value | description |
|
||||
| --------------------- | --------------- | -------------------------------------------------------------------------------------------------------------- |
|
||||
|-----------------------|-----------------|----------------------------------------------------------------------------------------------------------------|
|
||||
| DYNB_DYN_DOMAIN | undefined | required; `dyndns.example.com` |
|
||||
| DYNB_SERVICE_PROVIDER | undefined | required; `deSEC`, `duckdns`, `dynv6`, `inwx` |
|
||||
| DYNB_SERVICE_PROVIDER | undefined | required; `deSEC`, `duckdns`, `dynv6`, `inwx`, `ddnss`, `ipv64` |
|
||||
| DYNB_UPDATE_METHOD | undefined | required; `dyndns` or `domrobot` (with inwx) |
|
||||
| DYNB_IP_MODE | undefined | required; `4`, `6` or `64` for both |
|
||||
| DYNB_USERNAME | undefined | the requirement depends on your provider and the update method |
|
||||
|
||||
197
dynb.sh
197
dynb.sh
@@ -66,7 +66,7 @@ _response=
|
||||
_statusHostname=
|
||||
_statusUsername=
|
||||
_statusPassword=
|
||||
_version=0.3.0
|
||||
_version=0.3.5
|
||||
_userAgent="DynB/$_version github.com/EV21/dynb"
|
||||
_configFile=$HOME/.local/share/dynb/.env
|
||||
_statusFile=/tmp/dynb.status
|
||||
@@ -209,17 +209,12 @@ function getRemoteIP
|
||||
{
|
||||
local ip_version=$1
|
||||
local ip_check_server=$2
|
||||
if [[ -n $_DNS_checkServer ]]
|
||||
then
|
||||
curl --silent "$_interface_str" --user-agent "$_userAgent" \
|
||||
--ipv"${ip_version}" --dns-servers "$_DNS_checkServer" --location "${ip_check_server}"
|
||||
else
|
||||
curl --silent "$_interface_str" --user-agent "$_userAgent" \
|
||||
--ipv"${ip_version}" --location "${ip_check_server}"
|
||||
fi
|
||||
local curls_status_code=$?
|
||||
# shellcheck disable=2181
|
||||
if [[ $? -gt 0 ]]; then
|
||||
errorMessage "IPCheck (getRemoteIP ${1}) request failed"
|
||||
if [[ $curls_status_code -gt 0 ]]; then
|
||||
errorMessage "IPCheck (getRemoteIP $ip_version) request failed"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
@@ -263,8 +258,7 @@ function updateRecord
|
||||
fi
|
||||
}
|
||||
|
||||
# using DynDNS2 protocol
|
||||
function dynupdate
|
||||
function select_update_base_url
|
||||
{
|
||||
# default parameter values
|
||||
myip_str=myip
|
||||
@@ -274,6 +268,8 @@ function dynupdate
|
||||
DESEC_DYNDNS_UPDATE_URL="https://update.dedyn.io/?"
|
||||
DUCKDNS_DYNDNS_UPDATE_URL="https://www.duckdns.org/update?domains=$DYNB_DYN_DOMAIN&token=$DYNB_TOKEN&"
|
||||
DYNV6_DYNDNS_UPDATE_URL="https://dynv6.com/api/update?zone=$DYNB_DYN_DOMAIN&token=$DYNB_TOKEN&"
|
||||
DDNSS_DYNDNS_UPDATE_URL="https://ddnss.de/upd.php?key=$DYNB_TOKEN&host=$DYNB_DYN_DOMAIN&"
|
||||
IPV64NET_DYNDNS_UPDATE_URL="https://ipv64.net/nic/update?"
|
||||
|
||||
case $DYNB_SERVICE_PROVIDER in
|
||||
inwx* | INWX*)
|
||||
@@ -289,34 +285,37 @@ function dynupdate
|
||||
;;
|
||||
DuckDNS* | duckdns*)
|
||||
dyndns_update_url="${DUCKDNS_DYNDNS_UPDATE_URL}"
|
||||
myip_str=ipv4
|
||||
myip_str=ip
|
||||
myipv6_str=ipv6
|
||||
;;
|
||||
ddnss*)
|
||||
dyndns_update_url="${DDNSS_DYNDNS_UPDATE_URL}"
|
||||
## we are currently not using the syntax with ip auto detection
|
||||
myip_str=ip
|
||||
myipv6_str=ip6
|
||||
;;
|
||||
[Ii][Pp][Vv]64*)
|
||||
dyndns_update_url="${IPV64NET_DYNDNS_UPDATE_URL}"
|
||||
myip_str=ip
|
||||
myipv6_str=ip6
|
||||
;;
|
||||
*)
|
||||
errorMessage "$DYNB_SERVICE_PROVIDER is not supported"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# pre encode ip parameters
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]]; then
|
||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}&${myipv6_str}=${_new_IPv6}"
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == false ]]; then
|
||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}"
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == false ]] && [[ $_is_IPv6_enabled == true ]]; then
|
||||
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
|
||||
fi
|
||||
debugMessage "Update URL was: $dyndns_update_url"
|
||||
|
||||
## request ##
|
||||
function send_request
|
||||
{
|
||||
case $DYNB_SERVICE_PROVIDER in
|
||||
inwx* | INWX*)
|
||||
_response=$(curl --silent "$_interface_str" \
|
||||
--user-agent "$_userAgent" \
|
||||
--user "$DYNB_USERNAME":"$DYNB_PASSWORD" \
|
||||
"${dyndns_update_url}")
|
||||
analyse_response
|
||||
status_code=$?
|
||||
;;
|
||||
deSEC* | desec* | dedyn*)
|
||||
_response=$(curl --silent "$_interface_str" \
|
||||
@@ -324,41 +323,72 @@ function dynupdate
|
||||
--header "Authorization: Token $DYNB_TOKEN" \
|
||||
--get --data-urlencode "hostname=$DYNB_DYN_DOMAIN" \
|
||||
"${dyndns_update_url}")
|
||||
analyse_response
|
||||
status_code=$?
|
||||
;;
|
||||
dynv6* | duckDNS* | duckdns*)
|
||||
[Ii][Pp][Vv]64* )
|
||||
_response=$(curl --silent "$_interface_str" \
|
||||
--user-agent "$_userAgent" \
|
||||
--header "Authorization: Bearer $DYNB_TOKEN" \
|
||||
--request POST \
|
||||
--form "domain=$DYNB_DYN_DOMAIN" \
|
||||
"${dyndns_update_url}")
|
||||
analyse_response
|
||||
status_code=$?
|
||||
;;
|
||||
dynv6* | duckDNS* | duckdns* | ddnss*)
|
||||
_response=$(
|
||||
curl --silent "$_interface_str" \
|
||||
--user-agent "$_userAgent" \
|
||||
"${dyndns_update_url}"
|
||||
)
|
||||
"${dyndns_update_url}")
|
||||
analyse_response
|
||||
status_code=$?
|
||||
;;
|
||||
esac
|
||||
return $status_code
|
||||
}
|
||||
|
||||
function analyse_response
|
||||
{
|
||||
case $_response in
|
||||
good* | OK* | "addresses updated")
|
||||
good* | OK* | "addresses updated" | *Updated*hostname* | *'"info":"good"'*)
|
||||
if [[ $_response == "good 127.0.0.1" ]]; then
|
||||
errorMessage "$_response: Request ignored."
|
||||
return 1
|
||||
else
|
||||
infoMessage "$_response: The DynDNS update has been executed."
|
||||
_errorCounter=0
|
||||
infoMessage "The DynDNS update has been executed."
|
||||
debugMessage "Response: $_response"
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
nochg*)
|
||||
infoMessage "$_response: Nothing has changed, IP addresses are still up to date."
|
||||
*nochg*)
|
||||
infoMessage "Nothing has changed, IP addresses are still up to date."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
*'Bad Request'*)
|
||||
errorMessage "Bad Request."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
*'Too Many Requests'*)
|
||||
errorMessage "Too Many Request."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
abuse)
|
||||
errorMessage "$_response: Username is blocked due to abuse."
|
||||
errorMessage "Username is blocked due to abuse."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
badauth | 401)
|
||||
errorMessage "$_response: Invalid username password combination."
|
||||
*badauth* | 401 | *Unauthorized*)
|
||||
errorMessage "Invalid token or username password combination."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
badagent)
|
||||
errorMessage "$_response: Client disabled. Something is very wrong!"
|
||||
errorMessage "Client disabled. Something is very wrong!"
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
!donator)
|
||||
@@ -373,8 +403,9 @@ function dynupdate
|
||||
errorMessage "$_response: Hostname $DYNB_DYN_DOMAIN is invalid"
|
||||
return 1
|
||||
;;
|
||||
nohost)
|
||||
errorMessage "$_response: Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
||||
*nohost*)
|
||||
errorMessage "Hostname supplied does not exist under specified account, enter new login credentials before performing an additional request."
|
||||
debugMessage "Response: $_response"
|
||||
return 1
|
||||
;;
|
||||
numhost)
|
||||
@@ -391,7 +422,7 @@ function dynupdate
|
||||
;;
|
||||
*)
|
||||
if [[ "$_response" == "$_status" ]]; then
|
||||
errorMessage "An unknown response code has been received. $_response"
|
||||
errorMessage "An unknown response code has been received: $_response"
|
||||
return 1
|
||||
else
|
||||
errorMessage "unknown respnse code: $_response"
|
||||
@@ -401,6 +432,34 @@ function dynupdate
|
||||
esac
|
||||
}
|
||||
|
||||
# using DynDNS2 protocol
|
||||
function dynupdate
|
||||
{
|
||||
select_update_base_url
|
||||
|
||||
# pre encode ip parameters
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == true ]]
|
||||
then
|
||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}&${myipv6_str}=${_new_IPv6}"
|
||||
send_request
|
||||
request_status=$?
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == true ]] && [[ $_is_IPv6_enabled == false ]]
|
||||
then
|
||||
dyndns_update_url="${dyndns_update_url}${myip_str}=${_new_IPv4}"
|
||||
send_request
|
||||
request_status=$?
|
||||
fi
|
||||
if [[ $_is_IPv4_enabled == false ]] && [[ $_is_IPv6_enabled == true ]]
|
||||
then
|
||||
dyndns_update_url="${dyndns_update_url}${myipv6_str}=${_new_IPv6}"
|
||||
send_request
|
||||
request_status=$?
|
||||
fi
|
||||
debugMessage "Update URL was: $dyndns_update_url"
|
||||
return $request_status
|
||||
}
|
||||
|
||||
function setStatus
|
||||
{
|
||||
echo "_status=$1; _eventTime=$2; _errorCounter=$3; _statusHostname=$4; _statusUsername=$5; _statusPassword=$6" >/tmp/dynb.status
|
||||
@@ -410,10 +469,10 @@ function setStatus
|
||||
function checkStatus
|
||||
{
|
||||
case $_status in
|
||||
nochg*)
|
||||
*nochg*)
|
||||
if [[ _errorCounter -gt 1 ]]; then
|
||||
errorMessage "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"
|
||||
errorMessage "Fix your config and then delete $_statusFile or restart your docker container"
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
@@ -425,8 +484,8 @@ function checkStatus
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
badauth | 401)
|
||||
if [[ "$_statusUsername" == "$DYNB_USERNAME" && "$_statusPassword" == "$DYNB_PASSWORD" ]]; then
|
||||
*badauth* | 401 | *Unauthorized*)
|
||||
if [[ "$_statusUsername" == "$DYNB_USERNAME" && ("$_statusPassword" == "$DYNB_PASSWORD" || $_statusPassword == "$DYNB_TOKEN") ]]; then
|
||||
errorMessage "Invalid username password combination."
|
||||
return 1
|
||||
else rm "$_statusFile"
|
||||
@@ -435,8 +494,7 @@ function checkStatus
|
||||
;;
|
||||
badagent)
|
||||
errorMessage "Client is deactivated by provider."
|
||||
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 "Please file an issue at GitHub or try another client :)"
|
||||
return 1
|
||||
;;
|
||||
!donator)
|
||||
@@ -451,7 +509,7 @@ function checkStatus
|
||||
echo "If it still fails file an issue at github or try another client :)"
|
||||
return 1
|
||||
;;
|
||||
911 | 5*)
|
||||
911 | 5* | *'Too Many Requests'*)
|
||||
delta=$(($(date +%s) - _eventTime))
|
||||
if [[ $delta -lt 1800 ]]
|
||||
then
|
||||
@@ -461,6 +519,14 @@ function checkStatus
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
*'Bad Request'*)
|
||||
if [[ "$_statusUsername" == "$DYNB_USERNAME" && ("$_statusPassword" == "$DYNB_PASSWORD" || $_statusPassword == "$DYNB_TOKEN") ]]; then
|
||||
errorMessage "Bad Request: Please check your credentials, maybe your token is invalid."
|
||||
return 1
|
||||
else rm "$_statusFile"
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
if [[ _errorCounter -gt 1 ]]
|
||||
then
|
||||
@@ -528,7 +594,7 @@ function ipHasChanged
|
||||
dns_ip=$(echo "$dig_response" | head -n 1)
|
||||
fi
|
||||
_new_IPv6=$remote_ip
|
||||
debugMessage "IPv6 from remote IP check server: $_new_IPv6, IPv4 from DNS: $dns_ip"
|
||||
debugMessage "IPv6 from remote IP check server: $_new_IPv6, IPv6 from DNS: $dns_ip"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
@@ -559,7 +625,7 @@ function handleParameters
|
||||
then rm --verbose "$_statusFile"; exit 0
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
if [[ $_arg_debug == "on" ]]
|
||||
if [[ $_arg_debug == "on" ]] || [[ $DYNB_DEBUG == true ]]
|
||||
then _debug=1
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
@@ -619,9 +685,6 @@ function handleParameters
|
||||
then _is_IPv6_enabled=true
|
||||
fi
|
||||
|
||||
if [[ $DYNB_DEBUG == true ]]
|
||||
then _debug=1
|
||||
fi
|
||||
# shellcheck disable=SC2154
|
||||
if [[ -n $DYNB_IPv4_CHECK_SITE ]]
|
||||
then _ipv4_checker=$DYNB_IPv4_CHECK_SITE
|
||||
@@ -707,6 +770,15 @@ function doDomrobotUpdates
|
||||
fi
|
||||
}
|
||||
|
||||
function delete_status_file
|
||||
{
|
||||
if test -f "$_statusFile"
|
||||
then
|
||||
debugMessage "Delete status file with previous errors"
|
||||
rm "$_statusFile"
|
||||
fi
|
||||
}
|
||||
|
||||
function doDynDNS2Updates
|
||||
{
|
||||
changed=0
|
||||
@@ -722,14 +794,16 @@ function doDynDNS2Updates
|
||||
then
|
||||
debugMessage "checkStatus has no errors, try update"
|
||||
if dynupdate
|
||||
then debugMessage "DynDNS2 update success"
|
||||
then
|
||||
debugMessage "DynDNS2 update success"
|
||||
delete_status_file
|
||||
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"
|
||||
else debugMessage "Skip DynDNS2 update, IPs are up to date."
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -782,11 +856,8 @@ function check_internet_connection
|
||||
fi
|
||||
}
|
||||
|
||||
function main
|
||||
function read_config_file
|
||||
{
|
||||
# shellcheck disable=SC1091,SC1090
|
||||
source "$(dirname "$(realpath "$0")")/dynb-parsing.sh"
|
||||
|
||||
# shellcheck source=.env
|
||||
if test -f "$_configFile"
|
||||
then
|
||||
@@ -800,6 +871,15 @@ function main
|
||||
source "$alternativeConfig"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function main
|
||||
{
|
||||
# shellcheck disable=SC1091,SC1090
|
||||
source "$(dirname "$(realpath "$0")")/dynb-parsing.sh"
|
||||
|
||||
read_config_file
|
||||
|
||||
if test -f "$_statusFile"
|
||||
then
|
||||
debugMessage "read previous status file"
|
||||
@@ -817,6 +897,7 @@ function main
|
||||
while :
|
||||
do
|
||||
doUpdates
|
||||
debugMessage "wait $DYNB_INTERVAL seconds until next check"
|
||||
sleep $DYNB_INTERVAL
|
||||
done
|
||||
else doUpdates
|
||||
|
||||
Reference in New Issue
Block a user