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 WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory.
10 export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \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 #if [ -z "$IP_ADDRESS" ]; then
19 # # in our scheme, the single IP address that all our domains map to.
20 # IP_ADDRESS="10.28.42.20"
22 #if [ -z "$SERVER_ADMIN" ]; then
23 # # the email address (where first dot is replaced by @) for the administrator of the domain.
24 # SERVER_ADMIN="developer.cakelampvm.com"
26 #if [ -z "$MAIN_NAME_SERVER" ]; then
27 # # the name of the name server for the new domains (should already be configured).
28 # MAIN_NAME_SERVER="ns.cakelampvm.com"
30 #if [ -z "$MAIL_SERVER" ]; then
31 # # the name of the mail server for a new domain (should already be configured).
32 # MAIL_SERVER="mail.cakelampvm.com"
34 #if [ -z "$DISTRO" ]; then
35 # # the distribution name to be listed in info for the new domain or subdomain.
39 # main body of script.
41 if [[ $EUID != 0 ]]; then
42 echo "This script must be run as root or sudo."
46 old_domain="$1"; shift
48 if [ -z "$old_domain" ]; then
49 echo "This script needs a domain name to remove from DNS."
53 # if domain name has three or more components, then remove a subdomain.
54 # otherwise, remove a full domain.
55 if [[ $old_domain == *"."*"."* ]]; then
56 # remove a subdomain from the containing domain.
57 remove_subdomain "$old_domain"
60 # remove the full domain in DNS.
61 remove_domain_file "$old_domain"
62 remove_zone_for_domain "$old_domain"