Skip to content

Instantly share code, notes, and snippets.

View rdns.sh
#!/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
View utils.sh
#!/bin/bash
export FOREMAN_SERVER=$foremanserver/api
export FOREMAN_USER=apiuser
export FOREMAN_PASSWORD=$password
export FOREMAN_HOME=/usr/share/foreman
export PATH=$PATH:/usr/local/bin
reverseIp() {
local a i n
IFS=. read -r -a a <<< "$1"