bundlewrap/bundles/pppd/files/check_dyndns_update
Franziska Kunsmann bd10dc578f
Some checks failed
kunsi/bundlewrap/pipeline/head There was a failure building this commit
bundles/pppd: refactor check_dyndns_update
We don't care about what the DNS provider said when updating the ip
address. The only thing we care about is wether the current external ip
of the system matches the resolved ip address.
2021-08-14 08:00:43 +02:00

20 lines
570 B
Bash

#!/bin/bash
[[ -n "$DEBUG" ]] && set -x
interface="$(ip link show | awk '/ ppp/ {print substr($2, 1, length($2)-1)}')"
addr="$(ip addr show dev "$interface" | awk '/inet / {print $2}')"
resolved="$(dig +short "${domain}" A)"
if [[ -z "$addr" ]] || [[ -z "$resolved" ]]
then
echo "Address on '$interface' is '$addr' - resolved '$resolved'"
exit 3
elif [[ "$addr" == "$resolved" ]]
then
echo "Resolved IP for ${domain} matches current ip on $interface"
exit 0
else
echo "Resolved $resolved for ${domain}, but got $addr on $interface!"
exit 2
fi