#!/bin/bash # FILE: wagon:back/lib/ns_lookup_rdns # DESCRIPTION: Get a domain from an IP address # USAGE: rdns ip # OUTPUT: The domain for that IP # ERRORS: # 3: Not found # 4: Server down # 5: nslookup not found # 6: Bad usage source /etc/wagon/config domain="$(/usr/lib/wagon/ns_lookup_send "${1}")" case $? in 0) printf '%s' "${domain%.}" | cut -d'=' -f2 | xargs -0; exit 0;; 4) printf 'Domain for %s not found!\n' "${1}" >&2; exit 3;; 5) printf 'Nameserver not available: %s\n' "${DNS_MASTER}" >&2; exit 4;; 6) printf 'nslookup not installed!\n' >&2; exit 5;; *) printf 'Bad usage: %s %s\n' "${0}" "${@}" >&2; exit 6;; esac