containers-monit/nsupdate.sh
f ed9e013135
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
knot is always at knot.doma.in
2022-03-01 18:34:11 -03:00

26 lines
427 B
Bash
Executable file

#!/bin/sh
# Registers the local IPv6 address to the DNS
IP6="`whatsmyip6`"
KNOT="${KNOT:-knot.${DOMAIN}}"
test -z "${IP6}" && exit 1
test -z "${DOMAIN}" && exit 1
# Add a dot if the hostname contains the domain
echo "${HOSTNAME}" | grep -q "\.${DOMAIN}$" && DOT="."
knsupdate <<DNS
server ${KNOT}
zone ${DOMAIN}.
origin ${DOMAIN}.
ttl 60
del ${HOSTNAME}${DOT} AAAA
add ${HOSTNAME}${DOT} AAAA ${IP6}
send
quit
DNS
exit $?