+ # split up the full domain name into subdomain portion and containing domain.
+ local subdomain="${old_domain%.*.*}"
+ local containing_domain="${old_domain#*.}"
+
+ echo "removing subdomain $subdomain from containing domain $containing_domain"
+
+ local domain_file="/etc/bind/${containing_domain}.conf"
+ # see if config file already exists; if not, complain.
+ if [ ! -f "$domain_file" ]; then
+ echo "The domain configuration file for $old_domain is missing."
+ echo "It should already be present in: $domain_file"
+ echo "We cannot remove a subdomain if the containing domain isn't there."
+ exit 1
+ fi
+
+ # see if subdomain already present in config.
+ if ! grep -q "$old_domain" "$domain_file"; then
+ echo "The subdomain $subdomain is already missing from the domain"
+ echo "configuration file: $domain_file"
+ echo "Our work is apparently done for removing it."
+ return 0
+ fi
+
+ create_chomped_copy_of_file "$domain_file" "${old_domain}" 2