Set up ddclient
This commit is contained in:
19
mounts/ddclient/config/ddclient.conf.tpl
Normal file
19
mounts/ddclient/config/ddclient.conf.tpl
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
daemon=300 # check every 300 seconds
|
||||||
|
syslog=yes # log update msgs to syslog
|
||||||
|
pid=/var/run/ddclient/ddclient.pid # record PID in file.
|
||||||
|
ssl=yes # use ssl-support. Works with
|
||||||
|
# ssl-library
|
||||||
|
postscript=/data/postscript_gotify.sh # run script after updating. The
|
||||||
|
# new IP is added as argument.
|
||||||
|
|
||||||
|
usev4=webv4
|
||||||
|
|
||||||
|
##
|
||||||
|
## CloudFlare (www.cloudflare.com)
|
||||||
|
##
|
||||||
|
protocol=cloudflare, \
|
||||||
|
zone=dedicated.contact, \
|
||||||
|
ttl=1, \
|
||||||
|
login=token, \
|
||||||
|
password=$CLOUDFLARE_TOKEN \
|
||||||
|
$CLOUDFLARE_DOMAIN
|
||||||
2
mounts/ddclient/data/.gitignore
vendored
Normal file
2
mounts/ddclient/data/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
!entrypoint.sh
|
||||||
|
!postscript_gotify.sh
|
||||||
0
mounts/ddclient/data/README.md
Normal file
0
mounts/ddclient/data/README.md
Normal file
33
mounts/ddclient/data/entrypoint.sh
Executable file
33
mounts/ddclient/data/entrypoint.sh
Executable file
@@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# usage: file_env VAR [DEFAULT]
|
||||||
|
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
|
||||||
|
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
|
||||||
|
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
|
||||||
|
file_env() {
|
||||||
|
local var="$1"
|
||||||
|
local fileVar="${var}_FILE"
|
||||||
|
local def="${2:-}"
|
||||||
|
if [ "${!var:-}" ] && [ "${!fileVar:-}" ]; then
|
||||||
|
mysql_error "Both $var and $fileVar are set (but are exclusive)"
|
||||||
|
fi
|
||||||
|
local val="$def"
|
||||||
|
if [ "${!var:-}" ]; then
|
||||||
|
val="${!var}"
|
||||||
|
elif [ "${!fileVar:-}" ]; then
|
||||||
|
val="$(< "${!fileVar}")"
|
||||||
|
fi
|
||||||
|
export "$var"="$val"
|
||||||
|
unset "$fileVar"
|
||||||
|
}
|
||||||
|
|
||||||
|
cd /app
|
||||||
|
|
||||||
|
|
||||||
|
apk add --update gettext
|
||||||
|
|
||||||
|
file_env 'GOTIFY_TOKEN'
|
||||||
|
file_env 'CLOUDFLARE_TOKEN'
|
||||||
|
envsubst < /config/ddclient.conf.tpl > /config/ddclient.conf
|
||||||
|
|
||||||
|
/init "$@"
|
||||||
7
mounts/ddclient/data/postscript_gotify.sh
Executable file
7
mounts/ddclient/data/postscript_gotify.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
curl "$GOTIFY_ADDRESS/message" \
|
||||||
|
-X POST \
|
||||||
|
-H "X-Gotify-Key: $GOTIFY_TOKEN" \
|
||||||
|
-F "title=IP Address updated" \
|
||||||
|
-F "message=IP address detected as $1" \
|
||||||
|
-F "priority=5"
|
||||||
5
mounts/ddclient/secrets/README.md
Normal file
5
mounts/ddclient/secrets/README.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Contains the file `gotify_token`
|
||||||
|
Loadded in the postscript_gotify.sh to send a notification when a new IP is found
|
||||||
|
|
||||||
|
Contains the file `clourflare_token`
|
||||||
|
Token required to access the DNS API of cloudflare
|
||||||
@@ -10,7 +10,8 @@ services:
|
|||||||
- source: diun
|
- source: diun
|
||||||
target: /etc/diun/
|
target: /etc/diun/
|
||||||
secrets:
|
secrets:
|
||||||
- gotify_token
|
- source: diun_gotify_token
|
||||||
|
target: gotify_token
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
smokeping:
|
smokeping:
|
||||||
@@ -27,6 +28,28 @@ services:
|
|||||||
traefik.enable: true
|
traefik.enable: true
|
||||||
traefik.http.routers.smokeping.rule: HostRegexp(`smokeping{subdomain:(\.[a-z0-9-]+)?}.dedicated.contact`)
|
traefik.http.routers.smokeping.rule: HostRegexp(`smokeping{subdomain:(\.[a-z0-9-]+)?}.dedicated.contact`)
|
||||||
|
|
||||||
|
ddclient:
|
||||||
|
image: linuxserver/ddclient
|
||||||
|
environment:
|
||||||
|
GOTIFY_ADDRESS: http://gotify
|
||||||
|
GOTIFY_TOKEN_FILE: /run/secrets/gotify_token
|
||||||
|
CLOUDFLARE_DOMAIN: ${DDCLIENT_CLOUDFLARE_DOMAIN-dev.dedicated.contact}
|
||||||
|
CLOUDFLARE_TOKEN_FILE: /run/secrets/cloudflare_token
|
||||||
|
networks:
|
||||||
|
- gotify
|
||||||
|
volumes:
|
||||||
|
- ddclient:/config
|
||||||
|
- smokeping-data:/data
|
||||||
|
configs:
|
||||||
|
- source: ddclient
|
||||||
|
target: /config/
|
||||||
|
secrets:
|
||||||
|
- source: ddclient_gotify_token
|
||||||
|
target: gotify_token
|
||||||
|
- source: ddclient_cloudflare_token
|
||||||
|
target: cloudflare_token
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
docker:
|
docker:
|
||||||
external: true
|
external: true
|
||||||
@@ -46,13 +69,24 @@ volumes:
|
|||||||
type: none
|
type: none
|
||||||
o: bind
|
o: bind
|
||||||
device: ${MOUNT_DIR?}/smokeping/data/
|
device: ${MOUNT_DIR?}/smokeping/data/
|
||||||
|
ddclient:
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
o: bind
|
||||||
|
device: ${MOUNT_DIR?}/ddclient/data/
|
||||||
|
|
||||||
configs:
|
configs:
|
||||||
diun:
|
diun:
|
||||||
file: ${MOUNT_DIR?}/diun/config/
|
file: ${MOUNT_DIR?}/diun/config/
|
||||||
# smokeping:
|
# smokeping:
|
||||||
# file: ${MOUNT_DIR?}/smokeping/config/
|
# file: ${MOUNT_DIR?}/smokeping/config/
|
||||||
|
ddclient:
|
||||||
|
file: ${MOUNT_DIR?}/ddclient/config/
|
||||||
|
|
||||||
secrets:
|
secrets:
|
||||||
gotify_token:
|
diun_gotify_token:
|
||||||
file: ${MOUNT_DIR?}/diun/secrets/gotify_token
|
file: ${MOUNT_DIR?}/diun/secrets/gotify_token
|
||||||
|
ddclient_gotify_token:
|
||||||
|
file: ${MOUNT_DIR?}/ddclient/secrets/gotify_token
|
||||||
|
ddclient_cloudflare_token:
|
||||||
|
file: ${MOUNT_DIR?}/ddclient/secrets/cloudflare_token
|
||||||
|
|||||||
Reference in New Issue
Block a user