Add 'cloudbox' configuration.
This commit is contained in:
parent
d203da49c2
commit
b1af7d31ec
16 changed files with 200 additions and 0 deletions
30
roles/ddns-update/files/ddns-update
Executable file
30
roles/ddns-update/files/ddns-update
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
set -eu
|
||||
|
||||
. /etc/ddns-update/ddns-update.conf
|
||||
|
||||
DDHOST="https://www.ddnss.de/upd.php"
|
||||
|
||||
if ! DNSRESULT="$(host $DDNSNAME)" ; then
|
||||
echo "Could not resolve IP address for '$DDNSNAME', no update."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DNSIP4="$(echo \\"$DNSRESULT\\" | grep -m 1 -oE '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$' || true )"
|
||||
DNSIP6="$(echo \\"$DNSRESULT\\" | grep -m 1 -oE '[0-9a-f]{1,4}:.+:[0-9a-f]{1,4}' || true )"
|
||||
|
||||
REALIP4="$(wget -q -O - https://ip4.ddnss.de/meineip.php | \
|
||||
grep -m 1 -oE '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' || true )"
|
||||
REALIP6="$(wget -q -O - https://ip6.ddnss.de/meineip.php | \
|
||||
grep -m 1 -oE '[0-9a-f]{1,4}:.+:[0-9a-f]{1,4}' || true )"
|
||||
|
||||
echo "Current DNS: IPv4=$DNSIP4, IPv6=$DNSIP6."
|
||||
echo "Detected: IPv4=$REALIP4, IPv6=$REALIP6."
|
||||
|
||||
if [ "$REALIP4" == "$DNSIP4" -a "$REALIP6" == "$DNSIP6" ] ; then
|
||||
echo "IP address unchanged, no update."
|
||||
else
|
||||
echo "IP address changed: $DNSIP4 → ${REALIP4}, $DNSIP6 → ${REALIP6}, updating ddns."
|
||||
wget -q -O - $DDHOST'?key='$KEYAUTH'&host='$DDNSNAME'&ip='$REALIP4'&ip6='$REALIP6 \
|
||||
| grep -oE "Updated .+ hostname." || echo "Update not confirmed, it might have failed."
|
||||
fi
|
6
roles/ddns-update/files/ddns-update.service
Normal file
6
roles/ddns-update/files/ddns-update.service
Normal file
|
@ -0,0 +1,6 @@
|
|||
[Unit]
|
||||
Description=Update ddns
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/ddns-update
|
11
roles/ddns-update/files/ddns-update.timer
Normal file
11
roles/ddns-update/files/ddns-update.timer
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Update ddns IP-address
|
||||
|
||||
[Timer]
|
||||
OnBootSec=0
|
||||
OnUnitActiveSec=15min
|
||||
AccuracySec=3min
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Add table
Add a link
Reference in a new issue