mirror of
https://github.com/EV21/dynb.git
synced 2025-12-26 16:39:32 +01:00
Compare commits
36 Commits
noip
...
fcdddde456
| Author | SHA1 | Date | |
|---|---|---|---|
|
fcdddde456
|
|||
|
e2ddda5ba7
|
|||
|
24aa20be3b
|
|||
|
d92cdb2652
|
|||
|
4643331534
|
|||
|
fa15700e5d
|
|||
|
43b09d7145
|
|||
|
3b543754b3
|
|||
|
040aec7472
|
|||
|
eda5a69da2
|
|||
|
01eaa30523
|
|||
|
30c5373705
|
|||
|
4e26ff135d
|
|||
|
be2f4f3862
|
|||
|
93c1ed18d0
|
|||
|
2c23b1de6e
|
|||
|
f9507929da
|
|||
|
30e77c9722
|
|||
|
bb1d514b50
|
|||
|
c02dc68f17
|
|||
|
dcf9f1e7a2
|
|||
|
4d28f55ce9
|
|||
|
b8565eb38f
|
|||
|
ab330e9731
|
|||
|
262f7c3709
|
|||
|
5210c35400
|
|||
|
522a0f99bb
|
|||
|
3bf6b69ae8
|
|||
|
d139022295
|
|||
|
8997835903
|
|||
|
d6dc223794
|
|||
|
dc12f71d00
|
|||
|
5ba730cff1
|
|||
|
1104cf8505
|
|||
|
99a446f4c7
|
|||
|
f056e96e25
|
@@ -82,34 +82,24 @@ ignore_regexps = [
|
|||||||
## whenever you are tweaking this variable.
|
## whenever you are tweaking this variable.
|
||||||
##
|
##
|
||||||
section_regexps = [
|
section_regexps = [
|
||||||
('Features', [
|
('New', [
|
||||||
r'^[fF]eat\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
r'^:sparkles\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
||||||
]),
|
]),
|
||||||
('Added', [
|
('Changes', [
|
||||||
r'^[aA]dd\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
r'^:wrench\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
||||||
]),
|
|
||||||
('Changed', [
|
|
||||||
r'^[cC]hange\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
|
||||||
]),
|
|
||||||
('Deprecated', [
|
|
||||||
r'^[dD]epricated\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
|
||||||
]),
|
|
||||||
('Removed', [
|
|
||||||
r'^[rR]emove\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
|
||||||
]),
|
]),
|
||||||
('Fix', [
|
('Fix', [
|
||||||
r'^[fF]ix\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
r'^:bug\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
||||||
]),
|
|
||||||
('Security', [
|
|
||||||
r'^[sS]ec\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
|
||||||
]),
|
]),
|
||||||
('Documentation', [
|
('Documentation', [
|
||||||
r'^[dD]oc\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
r'^:memo\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
||||||
]),
|
]),
|
||||||
|
('Remove', [
|
||||||
|
r'^:fire\s*:\s*((dev|use?r|pkg|test|doc)\s*:\s*)?([^\n]*)$',
|
||||||
|
]),
|
||||||
|
|
||||||
|
('Other', None ## Match all lines
|
||||||
#('Other', None ## Match all lines
|
),
|
||||||
# ),
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,4 @@ repos:
|
|||||||
- "-l" # list files whose formatting differs from shfmt's
|
- "-l" # list files whose formatting differs from shfmt's
|
||||||
- "-i 2" # indent: 0 for tabs (default), >0 for number of spaces
|
- "-i 2" # indent: 0 for tabs (default), >0 for number of spaces
|
||||||
- "-ci" # switch cases will be indented
|
- "-ci" # switch cases will be indented
|
||||||
- "-w" # write result to file instead of stdout
|
- "-w" # write result to file instead of stdout
|
||||||
- repo: https://github.com/executablebooks/mdformat
|
|
||||||
rev: 0.7.9
|
|
||||||
hooks:
|
|
||||||
- id: mdformat
|
|
||||||
additional_dependencies:
|
|
||||||
- mdformat-gfm # GitHub Flavored Markdown support
|
|
||||||
36
CHANGELOG.md
36
CHANGELOG.md
@@ -1,50 +1,20 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
|
||||||
## 0.2.0 (2021-09-24)
|
## (unreleased)
|
||||||
|
|
||||||
### New
|
|
||||||
|
|
||||||
* :sparkles: enable parameter extensions for `docker run --interactive` [Eduard Veit]
|
|
||||||
|
|
||||||
* :sparkles: add pre-commit hooks for markdown. [Eduard Veit]
|
|
||||||
|
|
||||||
* :sparkles: change git hooks and add shfmt. [Eduard Veit]
|
|
||||||
|
|
||||||
* :sparkles: add pre-commit git hook for shellcheck. [Eduard Veit]
|
|
||||||
|
|
||||||
### Changes
|
|
||||||
|
|
||||||
* :wrench: remove md-toc from pre-commit. [Eduard Veit]
|
|
||||||
|
|
||||||
* :wrench: handle dns server selection. [Eduard Veit]
|
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
* :memo: update CHANGELOG.md. [Eduard Veit]
|
|
||||||
|
|
||||||
* :memo: document docker parameters. [Eduard Veit]
|
|
||||||
|
|
||||||
* :memo: change default dns server setting. [Eduard Veit]
|
|
||||||
|
|
||||||
* :memo: update CHANGELOG. [Eduard Veit]
|
|
||||||
|
|
||||||
* :memo: update README.md. [Eduard Veit]
|
* :memo: update README.md. [Eduard Veit]
|
||||||
|
|
||||||
### Other
|
### Other
|
||||||
|
|
||||||
* :art: lint README.md. [Eduard Veit]
|
|
||||||
|
|
||||||
* :art: add shfmt params to pre-commit check. [Eduard Veit]
|
|
||||||
|
|
||||||
* :art: fix shell style. [Eduard Veit]
|
|
||||||
|
|
||||||
* :recycle: seperate parsing logic. [Eduard Veit]
|
|
||||||
|
|
||||||
* :recycle: normalizing pre-commit configuration to a top-level map. [Eduard Veit]
|
* :recycle: normalizing pre-commit configuration to a top-level map. [Eduard Veit]
|
||||||
|
|
||||||
* :recycle: refactorings. [Eduard Veit]
|
* :recycle: refactorings. [Eduard Veit]
|
||||||
|
|
||||||
|
* Feature: :sparkles: add pre-commit git hook for shellcheck. [Eduard Veit]
|
||||||
|
|
||||||
* Refactor: :recycle: remove unused help message. [Eduard Veit]
|
* Refactor: :recycle: remove unused help message. [Eduard Veit]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
19
Dockerfile
19
Dockerfile
@@ -1,20 +1,5 @@
|
|||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
RUN apk update && apk add bash curl jq bind-tools
|
||||||
RUN \
|
|
||||||
apk update \
|
|
||||||
&& \
|
|
||||||
apk add \
|
|
||||||
bash \
|
|
||||||
curl \
|
|
||||||
jq \
|
|
||||||
bind-tools
|
|
||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
CMD /bin/bash /usr/src/app/dynb.sh
|
||||||
ENTRYPOINT ["/bin/bash", "/usr/src/app/dynb.sh"]
|
|
||||||
|
|
||||||
LABEL org.opencontainers.image.source="https://github.com/EV21/dynb"
|
|
||||||
LABEL org.opencontainers.image.description="DynB - dynamic DNS update client."
|
|
||||||
LABEL org.opencontainers.image.licenses="MIT"
|
|
||||||
97
README.md
97
README.md
@@ -1,65 +1,55 @@
|
|||||||
# 🔃 DynB
|
# 🔃 DynB
|
||||||
|
|
||||||
DynB - dynamic DNS update script, written in bash
|
DynB - dynamic DNS update script, written in bash
|
||||||
|
|
||||||
IPv4 (A) and IPv6 (AAAA) record updates are supported.
|
IPv4 (A) and IPv6 (AAAA) record updates are supported.
|
||||||
|
|
||||||
<!-- TOC -->
|
<!-- TOC -->
|
||||||
|
|
||||||
- [✨ Update Methods](#-update-methods)
|
- [✨ Update Methods](#-update-methods)
|
||||||
- [APIs](#apis)
|
- [APIs](#apis)
|
||||||
- [DynDNS2](#dyndns2)
|
- [DynDNS2](#dyndns2)
|
||||||
- [📦 Requirements](#-requirements)
|
- [📦 Requirements](#-requirements)
|
||||||
- [🚀 Installation](#-installation)
|
- [🚀 Installation](#-installation)
|
||||||
- [⚙ Configuration](#-configuration)
|
- [⚙ Configuration](#-configuration)
|
||||||
- [🏃 Run](#-run)
|
- [🏃 Run](#-run)
|
||||||
- [⏰ Cron](#-cron)
|
- [⏰ Cron](#-cron)
|
||||||
- [loop mode](#loop-mode)
|
|
||||||
- [crontab](#crontab)
|
|
||||||
- [🐟 docker](#-docker)
|
- [🐟 docker](#-docker)
|
||||||
- [environment variables](#environment-variables)
|
|
||||||
|
|
||||||
<!-- /TOC -->
|
<!-- /TOC -->
|
||||||
|
|
||||||
## ✨ Update Methods
|
## ✨ Update Methods
|
||||||
|
|
||||||
The following update methods are currently implemented:
|
The following update methods are currently implemented:
|
||||||
|
|
||||||
### APIs
|
### APIs
|
||||||
|
|
||||||
- INWX.com Domrobot JSON-RPC-API\
|
* INWX.com Domrobot JSON-RPC-API
|
||||||
Limitations:
|
Limitations:
|
||||||
- minimum TTL is 300 (5 minutes)
|
- minimum TTL is 300 (5 minutes)
|
||||||
|
|
||||||
### DynDNS2
|
### DynDNS2
|
||||||
|
|
||||||
- INWX.com
|
* INWX.com
|
||||||
- deSEC.io (dedyn.io)
|
* deSEC.io (dedyn.io)
|
||||||
- DuckDNS.org
|
* DuckDNS.org
|
||||||
- dynv6.com
|
* dynv6.com
|
||||||
|
|
||||||
## 📦 Requirements
|
## 📦 Requirements
|
||||||
|
|
||||||
- `curl` - The minimum requirement for all API requests.
|
* `curl` - The minimum requirement for all API requests.
|
||||||
- `dig` - You can get it by installing `dnsutils` (debian/ubuntu/ArchLinux), `bind-utils` (CentOS/RHEL), `bind-tools` (Alpine)
|
* `dig` - You can get it by installing `dnsutils` (debian/ubuntu/ArchLinux), `bind-utils` (CentOS/RHEL), `bind-tools` (Alpine)
|
||||||
|
|
||||||
also essential if you are using other APIs:
|
also essential if you are using other APIs:
|
||||||
|
|
||||||
- `jq` - Command-line JSON processor
|
* `jq` - Command-line JSON processor
|
||||||
|
|
||||||
## 🚀 Installation
|
## 🚀 Installation
|
||||||
|
|
||||||
Download the latest release
|
Download the latest release
|
||||||
|
|
||||||
or simply clone this repo
|
or simply clone this repo
|
||||||
|
```
|
||||||
```shell
|
|
||||||
git clone https://github.com/EV21/dynb.git
|
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 :point_down:
|
||||||
|
```
|
||||||
```shell
|
|
||||||
bash dynb.sh --link
|
bash dynb.sh --link
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -69,8 +59,7 @@ You can use a config in form of an `.env` file.
|
|||||||
Or you can just use CLI parameters.
|
Or you can just use CLI parameters.
|
||||||
|
|
||||||
Create `.env` in the app root directory or at `~/.local/share/dynb/.env`.
|
Create `.env` in the app root directory or at `~/.local/share/dynb/.env`.
|
||||||
|
```
|
||||||
```bash
|
|
||||||
DYNB_DYN_DOMAIN=dyndns.example.com
|
DYNB_DYN_DOMAIN=dyndns.example.com
|
||||||
|
|
||||||
## service provider could be deSEC, duckdns, dynv6, inwx
|
## service provider could be deSEC, duckdns, dynv6, inwx
|
||||||
@@ -93,23 +82,18 @@ DYNB_TOKEN=
|
|||||||
## 🏃 Run
|
## 🏃 Run
|
||||||
|
|
||||||
If you have a config file just run :point_down:
|
If you have a config file just run :point_down:
|
||||||
|
```
|
||||||
```bash
|
|
||||||
dynb
|
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.
|
||||||
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 :point_down:
|
||||||
|
```
|
||||||
```bash
|
|
||||||
dynb --help
|
dynb --help
|
||||||
```
|
```
|
||||||
|
```
|
||||||
```bash
|
|
||||||
dynb --ip-mode dualstack --update-method domrobot --domain dyndns.example.com --username user42 --password SuperSecretPassword
|
dynb --ip-mode dualstack --update-method domrobot --domain dyndns.example.com --username user42 --password SuperSecretPassword
|
||||||
```
|
```
|
||||||
|
```
|
||||||
```bash
|
|
||||||
dynb --ip-mode dualstack --update-method dyndns --provider inwx --domain dyndns.example.com --username user42 --password SuperSecretPassword
|
dynb --ip-mode dualstack --update-method dyndns --provider inwx --domain dyndns.example.com --username user42 --password SuperSecretPassword
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -124,29 +108,18 @@ Just use the parameter `--interval 60` or the environment variable `DYNB_INTERVA
|
|||||||
### crontab
|
### crontab
|
||||||
|
|
||||||
execute :point_down:
|
execute :point_down:
|
||||||
|
```
|
||||||
```bash
|
|
||||||
crontab -e
|
crontab -e
|
||||||
```
|
```
|
||||||
|
|
||||||
then enter :point_down: to run dynb every five minutes.
|
then enter :point_down: to run dynb every five minutes.
|
||||||
|
```
|
||||||
```bash
|
|
||||||
*/5 * * * * $HOME/.local/bin/dynb >> $HOME/.local/share/dynb/dynb-cron.log
|
*/5 * * * * $HOME/.local/bin/dynb >> $HOME/.local/share/dynb/dynb-cron.log
|
||||||
```
|
```
|
||||||
|
|
||||||
alternative with docker and parameters::
|
|
||||||
|
|
||||||
```bash
|
|
||||||
*/5 * * * * docker run --interactive --tty --rm --network host ev21/dynb:latest --ip-mode 64 --update-method domrobot --domain dyndns.example.com --username user42 --password SuperSecretPassword
|
|
||||||
```
|
|
||||||
|
|
||||||
Note, cron typically does not use the users PATH variable.
|
Note, cron typically does not use the users PATH variable.
|
||||||
|
|
||||||
## 🐟 docker
|
## 🐟 docker
|
||||||
|
|
||||||
This is an example of a `docker-compose.yml` file. If you are using IPv6 make sure the routing works properly with your docker container. Note: [IPv6 networking](https://docs.docker.com/config/daemon/ipv6/) is only supported on Docker daemons running on Linux hosts.
|
This is an example of a `docker-compose.yml` file. If you are using IPv6 make sure the routing works properly with your docker container.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
version: '3.4'
|
version: '3.4'
|
||||||
|
|
||||||
@@ -167,20 +140,18 @@ services:
|
|||||||
- DYNB_PASSWORD=SuperSecretPassword
|
- DYNB_PASSWORD=SuperSecretPassword
|
||||||
- DYNB_INTERVAL=60
|
- DYNB_INTERVAL=60
|
||||||
```
|
```
|
||||||
|
|
||||||
## environment variables
|
## environment variables
|
||||||
|
| variable | default value | description |
|
||||||
| variable | default value | description |
|
| --------------------- | --------------- | --------------------------------------------- |
|
||||||
| --------------------- | --------------- | -------------------------------------------------------------------------------------------------------------- |
|
| DYNB_DYN_DOMAIN | undefined | required; `dyndns.example.com` |
|
||||||
| 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` |
|
| DYNB_UPDATE_METHOD | undefined | required; `dyndns` or `domrobot` (with inwx) |
|
||||||
| DYNB_UPDATE_METHOD | undefined | required; `dyndns` or `domrobot` (with inwx) |
|
| DYNB_IP_MODE | undefined | required; `4`, `6` or `64` for both |
|
||||||
| DYNB_IP_MODE | undefined | required; `4`, `6` or `64` for both |
|
| DYNB_USERNAME | undefined | the requirement depends on your provider and the update method |
|
||||||
| DYNB_USERNAME | undefined | the requirement depends on your provider and the update method |
|
| DYNB_PASSWORD | undefined | the requirement depends on your provider and the update method |
|
||||||
| DYNB_PASSWORD | undefined | the requirement depends on your provider and the update method |
|
| DYNB_TOKEN | undefined | the requirement depends on your provider and the update method |
|
||||||
| DYNB_TOKEN | undefined | the requirement depends on your provider and the update method |
|
| DYNB_INTERVAL | undefined | without this setting the script/docker container will run one time and exits |
|
||||||
| DYNB_INTERVAL | undefined | without this setting the script/docker container will run one time and exits |
|
| DYNB_DEBUG | undefined | more console outputs |
|
||||||
| DYNB_DEBUG | undefined | more console outputs |
|
| DYNB_IPv4_CHECK_SITE | api64.ipify.org | You need a website or Web-API that outputs your remote IP |
|
||||||
| DYNB_IPv4_CHECK_SITE | api64.ipify.org | You need a website or Web-API that outputs your remote IP |
|
| DYNB_IPv6_CHECK_SITE | api64.ipify.org | You need a website or Web-API that outputs your remote IP |
|
||||||
| DYNB_IPv6_CHECK_SITE | api64.ipify.org | You need a website or Web-API that outputs your remote IP |
|
|
||||||
| DYNB_DNS_CHECK_SERVER | undefined | If you are using a local DNS Resolver/Server make sure it answers with the public answer or set another server |
|
| DYNB_DNS_CHECK_SERVER | undefined | If you are using a local DNS Resolver/Server make sure it answers with the public answer or set another server |
|
||||||
|
|||||||
111
dynb.sh
111
dynb.sh
@@ -51,7 +51,6 @@ _network_interface=
|
|||||||
######################################################
|
######################################################
|
||||||
## You don't need to change the following variables ##
|
## You don't need to change the following variables ##
|
||||||
_INWX_JSON_API_URL=https://api.domrobot.com/jsonrpc/
|
_INWX_JSON_API_URL=https://api.domrobot.com/jsonrpc/
|
||||||
_internet_connectivity_test_server=https://www.google.de
|
|
||||||
_new_IPv4=
|
_new_IPv4=
|
||||||
_new_IPv6=
|
_new_IPv6=
|
||||||
_dns_records=
|
_dns_records=
|
||||||
@@ -66,7 +65,7 @@ _response=
|
|||||||
_statusHostname=
|
_statusHostname=
|
||||||
_statusUsername=
|
_statusUsername=
|
||||||
_statusPassword=
|
_statusPassword=
|
||||||
_version=0.3.0
|
_version=0.1.2
|
||||||
_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
|
||||||
@@ -74,31 +73,6 @@ _debug=0
|
|||||||
_minimum_looptime=60
|
_minimum_looptime=60
|
||||||
_loopMode=0
|
_loopMode=0
|
||||||
|
|
||||||
# Ansi color code variables
|
|
||||||
yellow_color="\e[0;33m"
|
|
||||||
green_color="\e[0;92m"
|
|
||||||
expand_bg="\e[K"
|
|
||||||
red_color_bg="\e[0;101m${expand_bg}"
|
|
||||||
bold="\e[1m"
|
|
||||||
reset_color_modification="\e[0m"
|
|
||||||
|
|
||||||
REGEX_IPv4="^(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])$"
|
|
||||||
REGEX_IPv6="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$"
|
|
||||||
|
|
||||||
function is_IPv4_address() {
|
|
||||||
if [[ $1 =~ $REGEX_IPv4 ]]
|
|
||||||
then return 0
|
|
||||||
else return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function is_IPv6_address() {
|
|
||||||
if [[ $1 =~ $REGEX_IPv6 ]]
|
|
||||||
then return 0
|
|
||||||
else return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function loopMode() {
|
function loopMode() {
|
||||||
if [[ $_loopMode -eq 1 ]]; then
|
if [[ $_loopMode -eq 1 ]]; then
|
||||||
return 0
|
return 0
|
||||||
@@ -116,18 +90,16 @@ function debugMode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function infoMessage() {
|
function infoMessage() {
|
||||||
echo -e "${green_color}$(logtime) INFO: $*${reset_color_modification}"
|
echo "$(logtime) INFO: $*"
|
||||||
}
|
}
|
||||||
|
|
||||||
function debugMessage() {
|
function debugMessage() {
|
||||||
if debugMode; then
|
if debugMode; then
|
||||||
echo -e "${yellow_color}$(logtime) DEBUG: ${*}${reset_color_modification}"
|
echo "$(logtime) DEBUG: $*"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function errorMessage() {
|
function errorMessage() { printf "$(logtime) ERROR: %s\n" "$*" >&2; }
|
||||||
echo -e "${red_color_bg}${bold}$(logtime) ERROR: $*${reset_color_modification}" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
function logtime() {
|
function logtime() {
|
||||||
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
|
||||||
@@ -237,7 +209,7 @@ function updateRecord() {
|
|||||||
--request POST $_INWX_JSON_API_URL \
|
--request POST $_INWX_JSON_API_URL \
|
||||||
--data "$request"
|
--data "$request"
|
||||||
)
|
)
|
||||||
infoMessage "$(echo "$_response" | jq --raw-output '.msg')\n Domain: $DYNB_DYN_DOMAIN\n New IPv${1}: $IP"
|
echo -e "$(echo "$_response" | jq --raw-output '.msg')\n Domain: $DYNB_DYN_DOMAIN\n new IPv${1}: $IP"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,7 +223,6 @@ function dynupdate() {
|
|||||||
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=$DYNB_DYN_DOMAIN&token=$DYNB_TOKEN&"
|
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&"
|
DYNV6_DYNDNS_UPDATE_URL="https://dynv6.com/api/update?zone=$DYNB_DYN_DOMAIN&token=$DYNB_TOKEN&"
|
||||||
NOIP_DYNDNS_UPDATE_URL="https://dynupdate.no-ip.com/nic/update?hostname=$DYNB_DYN_DOMAIN&"
|
|
||||||
|
|
||||||
case $DYNB_SERVICE_PROVIDER in
|
case $DYNB_SERVICE_PROVIDER in
|
||||||
inwx* | INWX*)
|
inwx* | INWX*)
|
||||||
@@ -260,9 +231,6 @@ function dynupdate() {
|
|||||||
deSEC* | desec* | dedyn*)
|
deSEC* | desec* | dedyn*)
|
||||||
dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}"
|
dyndns_update_url="${DESEC_DYNDNS_UPDATE_URL}"
|
||||||
;;
|
;;
|
||||||
noip* | no-ip*)
|
|
||||||
dyndns_update_url="$NOIP_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
|
||||||
@@ -293,7 +261,7 @@ function dynupdate() {
|
|||||||
|
|
||||||
## request ##
|
## request ##
|
||||||
case $DYNB_SERVICE_PROVIDER in
|
case $DYNB_SERVICE_PROVIDER in
|
||||||
inwx* | INWX* | noip* | no-ip*)
|
inwx* | INWX*)
|
||||||
_response=$(curl --silent "$_interface_str" \
|
_response=$(curl --silent "$_interface_str" \
|
||||||
--user-agent "$_userAgent" \
|
--user-agent "$_userAgent" \
|
||||||
--user "$DYNB_USERNAME":"$DYNB_PASSWORD" \
|
--user "$DYNB_USERNAME":"$DYNB_PASSWORD" \
|
||||||
@@ -315,7 +283,6 @@ function dynupdate() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
@@ -460,11 +427,6 @@ function ipHasChanged() {
|
|||||||
case ${1} in
|
case ${1} in
|
||||||
4)
|
4)
|
||||||
remote_ip=$(getRemoteIP 4 $_ipv4_checker)
|
remote_ip=$(getRemoteIP 4 $_ipv4_checker)
|
||||||
if ! is_IPv4_address "$remote_ip"
|
|
||||||
then
|
|
||||||
errorMessage "The response from the IP check server is not an IPv4 address: $remote_ip"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [[ $DYNB_UPDATE_METHOD == domrobot ]]; then
|
if [[ $DYNB_UPDATE_METHOD == domrobot ]]; then
|
||||||
dns_ip=$(getDNSIP A)
|
dns_ip=$(getDNSIP A)
|
||||||
else
|
else
|
||||||
@@ -477,20 +439,13 @@ function ipHasChanged() {
|
|||||||
errorMessage "DNS request failed $dig_response"
|
errorMessage "DNS request failed $dig_response"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
# If the dns resolver lists multiple records in the answer section we filter the first line
|
dns_ip=$dig_response
|
||||||
# using short option "-n" and not "--lines" because of alpines limited BusyBox head command
|
|
||||||
dns_ip=$(echo "$dig_response" | head -n 1)
|
|
||||||
fi
|
fi
|
||||||
_new_IPv4=$remote_ip
|
_new_IPv4=$remote_ip
|
||||||
debugMessage "IPv4 from remote IP check server: $_new_IPv4, IPv4 from DNS: $dns_ip"
|
debugMessage "New IPv4: $_new_IPv4 old was: $dns_ip"
|
||||||
;;
|
;;
|
||||||
6)
|
6)
|
||||||
remote_ip=$(getRemoteIP 6 $_ipv6_checker)
|
remote_ip=$(getRemoteIP 6 $_ipv6_checker)
|
||||||
if ! is_IPv6_address "$remote_ip"
|
|
||||||
then
|
|
||||||
errorMessage "The response from the IP check server is not an IPv6 address: $remote_ip"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
if [[ $DYNB_UPDATE_METHOD == domrobot ]]; then
|
if [[ $DYNB_UPDATE_METHOD == domrobot ]]; then
|
||||||
dns_ip=$(getDNSIP AAAA)
|
dns_ip=$(getDNSIP AAAA)
|
||||||
else
|
else
|
||||||
@@ -503,22 +458,18 @@ function ipHasChanged() {
|
|||||||
errorMessage "DNS request failed $dig_response"
|
errorMessage "DNS request failed $dig_response"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
# If the dns server lists multiple records in the answer section we filter the first line
|
dns_ip=$dig_response
|
||||||
dns_ip=$(echo "$dig_response" | head -n 1)
|
|
||||||
fi
|
fi
|
||||||
_new_IPv6=$remote_ip
|
_new_IPv6=$remote_ip
|
||||||
debugMessage "IPv6 from remote IP check server: $_new_IPv6, IPv4 from DNS: $dns_ip"
|
debugMessage "New IPv6: $_new_IPv6 old was: $dns_ip"
|
||||||
;;
|
;;
|
||||||
*) ;;
|
*) ;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [[ "$remote_ip" == "$dns_ip" ]]; then
|
if [[ "$remote_ip" == "$dns_ip" ]]; then
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
case ${1} in
|
|
||||||
4) infoMessage "New IPv4: $_new_IPv4 old was: $dns_ip";;
|
|
||||||
6) infoMessage "New IPv6: $_new_IPv6 old was: $dns_ip";;
|
|
||||||
esac
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -729,43 +680,6 @@ function doUpdates() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ipv6_is_not_working() {
|
|
||||||
curl --ipv6 --head --silent --max-time 1 "$_internet_connectivity_test_server" > /dev/null
|
|
||||||
status_code=$?
|
|
||||||
if [[ $status_code -gt 0 ]]
|
|
||||||
then return 0
|
|
||||||
else return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function ipv4_is_not_working() {
|
|
||||||
curl --ipv4 --head --silent --max-time 1 "$_internet_connectivity_test_server" > /dev/null
|
|
||||||
status_code=$?
|
|
||||||
if [[ $status_code -gt 0 ]]
|
|
||||||
then return 0
|
|
||||||
else return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_internet_connection() {
|
|
||||||
if [[ $_is_IPv4_enabled == true ]]
|
|
||||||
then
|
|
||||||
if ipv4_is_not_working
|
|
||||||
then
|
|
||||||
_is_IPv4_enabled="false"
|
|
||||||
errorMessage "Your IPv4 internet connection does not work."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
if [[ $_is_IPv6_enabled == true ]]
|
|
||||||
then
|
|
||||||
if ipv6_is_not_working
|
|
||||||
then
|
|
||||||
_is_IPv6_enabled="false"
|
|
||||||
errorMessage "Your IPv6 internet connection does not work."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
## MAIN method ##
|
## MAIN method ##
|
||||||
#################
|
#################
|
||||||
@@ -793,7 +707,6 @@ function dynb() {
|
|||||||
## parameters and checks
|
## parameters and checks
|
||||||
handleParameters
|
handleParameters
|
||||||
checkDependencies
|
checkDependencies
|
||||||
check_internet_connection
|
|
||||||
|
|
||||||
if loopMode; then
|
if loopMode; then
|
||||||
while :; do
|
while :; do
|
||||||
@@ -813,3 +726,5 @@ function dynb() {
|
|||||||
|
|
||||||
dynb "${@}"
|
dynb "${@}"
|
||||||
exit $?
|
exit $?
|
||||||
|
|
||||||
|
# ] <-- needed because of Argbash
|
||||||
|
|||||||
Reference in New Issue
Block a user