3 # performs the inverse function of add_domain by deconfiguring a domain
4 # in bind. the domain needs to have been set up by add_domain, or this will
7 # Author: Chris Koeritz
9 export THISDIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory.
10 export FEISTY_MEOW_APEX="$( \cd "$THISDIR/../.." && \pwd )"
12 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
13 source "$FEISTY_MEOW_SCRIPTS/system/common_sysadmin.sh"
15 # some defaults that are convenient for current purposes.
16 # existing values will be respected over our defaults.
18 # main body of script.
20 if [[ $EUID != 0 ]]; then
21 echo "This script must be run as root or sudo."
25 old_domain="$1"; shift
27 if [ -z "$old_domain" ]; then
28 echo "This script needs a domain name to remove from DNS."
32 # if domain name has three or more components, then remove a subdomain.
33 # otherwise, remove a full domain.
34 if [[ $old_domain == *"."*"."* ]]; then
35 # remove a subdomain from the containing domain.
36 remove_subdomain "$old_domain"
39 # remove the full domain in DNS.
40 remove_domain_file "$old_domain"
41 remove_zone_for_domain "$old_domain"