From b119c75c98233f2938bc8dd4a6efe5f91ec045b4 Mon Sep 17 00:00:00 2001 From: "Andreas B. Mundt" Date: Sat, 30 Mar 2019 18:39:12 +0300 Subject: [PATCH] Fixes for the DDNS setup. --- roles/ddns-update/files/ddns-update | 9 +++++++-- roles/ddns-update/files/ddns-update.timer | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/roles/ddns-update/files/ddns-update b/roles/ddns-update/files/ddns-update index 3285250..00c4bc8 100755 --- a/roles/ddns-update/files/ddns-update +++ b/roles/ddns-update/files/ddns-update @@ -10,14 +10,19 @@ if ! DNSRESULT="$(host $DDNSNAME)" ; then 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 )" +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 )" +if [ -z "$REALIP4" -a -z "$REALIP6" ] ; then + echo "Could not detect real IP addresses, exiting." + exit 0 +fi + echo "Current DNS: IPv4=$DNSIP4, IPv6=$DNSIP6." echo "Detected: IPv4=$REALIP4, IPv6=$REALIP6." diff --git a/roles/ddns-update/files/ddns-update.timer b/roles/ddns-update/files/ddns-update.timer index 28e8e2a..0fb72ec 100644 --- a/roles/ddns-update/files/ddns-update.timer +++ b/roles/ddns-update/files/ddns-update.timer @@ -3,7 +3,7 @@ Description=Update ddns IP-address [Timer] OnBootSec=0 -OnUnitActiveSec=15min +OnUnitActiveSec=20min AccuracySec=3min