containers-monit/nsupdate.sh

26 lines
427 B
Bash
Raw Normal View History

2021-04-01 18:49:14 +00:00
#!/bin/sh
# Registers the local IPv6 address to the DNS
IP6="`whatsmyip6`"
2022-03-01 21:33:23 +00:00
KNOT="${KNOT:-knot.${DOMAIN}}"
2021-04-01 18:49:14 +00:00
test -z "${IP6}" && exit 1
test -z "${DOMAIN}" && exit 1
2021-04-01 19:56:20 +00:00
# Add a dot if the hostname contains the domain
echo "${HOSTNAME}" | grep -q "\.${DOMAIN}$" && DOT="."
2021-04-01 18:49:14 +00:00
knsupdate <<DNS
server ${KNOT}
zone ${DOMAIN}.
origin ${DOMAIN}.
ttl 60
2022-01-20 20:17:18 +00:00
del ${HOSTNAME}${DOT} AAAA
2021-04-01 19:56:20 +00:00
add ${HOSTNAME}${DOT} AAAA ${IP6}
2021-04-01 18:49:14 +00:00
send
quit
DNS
exit $?