servers/roles/dnsmasq/templates/dns-update.j2

30 lines
521 B
Plaintext
Raw Normal View History

#!/bin/sh
domain={{ domain }}
ldap_user={{ password.ldap_user }}
ttl=3600
address="${3}"
case "${1}" in
add)
host="${4}"
kinit -k "${ldap_user}"
nsupdate -g <<EOF
update add ${host}.${domain} ${ttl} A ${address}
send
EOF
;;
old)
if [ -n "${DNSMASQ_OLD_HOSTNAME}" -a -n "${DNSMASQ_SUPPLIED_HOSTNAME}" ] ; then
kinit -k "${ldap_user}"
nsupdate -g <<EOF
update del ${DNSMASQ_OLD_HOSTNAME}.${domain}
update add ${DNSMASQ_SUPPLIED_HOSTNAME}.${domain} ${ttl} A ${address}
send
EOF
fi
;;
# TODO del, probably
esac