-# some defaults that are convenient for current purposes.
-# hmmm: these would need to be parameterized somehow for this script to become really general.
-
-# in our scheme, the single IP address that all our domains map to.
-IP_ADDRESS="10.28.42.20"
-# the email address (where first dot is replaced by @) for the administrator of the domain.
-SERVER_ADMIN="fred.cakelampvm.com"
-# the name of the name server for the new domains (should already be configured).
-MAIN_NAME_SERVER="ns.cakelampvm.com"
-# the name of the mail server for a new domain (should already be configured).
-MAIL_SERVER="mail.cakelampvm.com"
-# the distribution name to be listed in info for the new domain or subdomain.
-DISTRO="ubuntu"
-
-# creates a totally new domain config file for DNS.
-function write_new_domain_file()
-{
- local domain_name="$1"; shift
-
- local domain_file="/etc/bind/${domain_name}.conf"
-
- echo "adding a totally new domain called $domain_name"
- 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 "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 "
-\$TTL 1W
-@ IN SOA @ ${SERVER_ADMIN}. (
- 2017100801 ; serial
- 2H ; refresh
- 8M ; retry
- 14D ; expiry
- 6H ) ; minimum
-
- IN NS ${MAIN_NAME_SERVER}.
- IN MX 10 ${MAIL_SERVER}.
-
-${domain_name}. IN A ${IP_ADDRESS}
- IN HINFO \"linux server\" \"${DISTRO}\"
-" >"$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
-
- local domain_file="/etc/bind/${domain_name}.conf"
-
- echo "adding a new domain configured by ${domain_file} into"
- echo "the named.conf.local configuration file."
-
- # 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; };
-};