getting changes from cakelampvm
[feisty_meow.git] / scripts / system / add_domain.sh
index 00cf6de043a739083202e0a9a4757e5cdae1d69b..3c9df992983372a976865d7e91039c87b5f2d145 100644 (file)
@@ -33,11 +33,13 @@ function write_new_domain_file()
   echo "using the config file: $domain_file"
 
   if [ -f $domain_file ]; then
+    echo
     echo "The domain configuration file already exists at:"
     echo "  $domain_file"
-    echo "Please remove this file before proceeding, if it is junk.  For example:"
-    echo "  sudo rm $domain_file"
-    exit 1
+    echo "Since we don't want to tear that down if it has specialized configuration"
+    echo "data in it, we will just leave it in place and consider our job done."
+    echo
+    exit 0
   fi
 
   echo "
@@ -52,13 +54,12 @@ function write_new_domain_file()
        IN NS           ${MAIN_NAME_SERVER}.
        IN MX   10      ${MAIL_SERVER}.
 
-${domain}.     IN A    ${IP_ADDRESS}
+${domain_name}.        IN A    ${IP_ADDRESS}
        IN HINFO        \"linux server\" \"${DISTRO}\"
-"
-#fix
-# >"$domain_file"
+" >"$domain_file"
 }
 
+# hooks up a new config file into bind's list of zones.
 function add_zone_for_new_domain()
 {
   local domain_name="$1"; shift
@@ -68,18 +69,17 @@ function add_zone_for_new_domain()
   echo "adding a new domain configured by ${domain_file} into"
   echo "the named.conf.local configuration file."
 
-# need to write the reference to the new conf file in the zone list.
-
-echo "
+  # append the reference to the new conf file in the zone list.
+  echo "
 zone \"${domain_name}\" in {
        file \"${domain_file}\";
        type master;
        allow-query { any; };
 };
-"
-#fix
-#>> /etc/bind9/named.conf.local
 
+////////////////////////////////////////////////////////////////////////////
+
+" >> /etc/bind/named.conf.local
 }
 
 # adds a new subdomain under a containing domain.
@@ -115,9 +115,7 @@ function add_new_subdomain()
   echo "
 ${subdomain}.${containing_domain}.    IN A    ${IP_ADDRESS}
         IN HINFO \"linux server\" \"${DISTRO}\"
-"
-#fix
-#>> /etc/bind/${containing_domain}.conf
+" >> /etc/bind/${containing_domain}.conf
 
 }
 
@@ -134,7 +132,7 @@ function restart_bind()
 
 # main body of script.
 
-if (( $EUID != 0 )); then
+if [[ $EUID != 0 ]]; then
   echo "This script must be run as root or sudo."
   exit 1
 fi