Created
January 16, 2014 00:20
-
-
Save ddoc/8447483 to your computer and use it in GitHub Desktop.
rdns creation script for foreman hooks https://github.com/theforeman/foreman_hooks. More information at: http://www.brian2.net/posts/foreman_hooks_aws_vpc/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. /usr/share/foreman/config/hooks.d/lib/utils.sh | |
. $FOREMAN_HOME/config/hooks.d/lib/hook_functions.sh | |
set -x | |
IP=$(hook_data host.ip) | |
DNSNAME=$(hook_data host.name) | |
REVERSE=$(reverseIp ${IP}) | |
rdns_create() { | |
echolog IP ${IP} calling nsupdate: dns3.server.name update add ${REVERSE}.in-addr.arpa. 86400 PTR $DNSNAME | |
cat << EOF | nsupdate -y 'VIEW******************' | |
server dns.server.name | |
update add ${REVERSE}.in-addr.arpa. 86400 PTR $DNSNAME | |
send | |
quit | |
EOF | |
} | |
rdns_destroy() { | |
echolog IP: $IP calling nsupdate: dns.server.name update delete ${REVERSE}.in-addr.arpa. PTR $DNSNAME | |
cat << EOF | nsupdate -y 'VIEW******************' | |
server dns.server.name | |
update delete ${REVERSE}.in-addr.arpa. PTR $DNSNAME | |
send | |
quit | |
EOF | |
} | |
case "$HOOK_EVENT" in | |
create) | |
rdns_create | |
;; | |
destroy) | |
rdns_destroy | |
;; | |
update) | |
echolog no action for update | |
;; | |
*) | |
echo "Usage: run_hooks {create|destroy|update}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment