3 # this set of functions serve the main purpose of adding new domains or
4 # subdomains to the bind9 DNS server on the current host. it is currently
5 # highly specific to running a bunch of domains on a linux VM, where the VM
6 # has one IP address. note that the bind 'named' must already be configured.
7 # also, it is assumed that, if a subdomain is being added, then the containing
8 # domain has already been configured and is configured in a file similar to
9 # "blah.com.conf" in /etc/bind.
11 # Author: Chris Koeritz
13 export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory.
14 export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
16 source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
17 source "$FEISTY_MEOW_SCRIPTS/system/common_sysadmin.sh"
19 # some defaults that are convenient for current purposes.
20 # existing values will be respected over our defaults.
22 if [ -z "$IP_ADDRESS" ]; then
23 # in our scheme, the single IP address that all our domains map to.
24 IP_ADDRESS="10.28.42.20"
26 if [ -z "$SERVER_ADMIN" ]; then
27 # the email address (where first dot is replaced by @) for the administrator of the domain.
28 SERVER_ADMIN="developer.cakelampvm.com"
30 if [ -z "$MAIN_NAME_SERVER" ]; then
31 # the name of the name server for the new domains (should already be configured).
32 MAIN_NAME_SERVER="ns.cakelampvm.com"
34 if [ -z "$MAIL_SERVER" ]; then
35 # the name of the mail server for a new domain (should already be configured).
36 MAIL_SERVER="mail.cakelampvm.com"
38 if [ -z "$DISTRO" ]; then
39 # the distribution name to be listed in info for the new domain or subdomain.
43 # main body of script.
45 if [[ $EUID != 0 ]]; then
46 echo "This script must be run as root or sudo."
50 new_domain="$1"; shift
52 if [ -z "$new_domain" ]; then
53 echo "This script needs a domain name to add to DNS."
57 # if domain name has three or more components, then add a subdomain.
58 # otherwise, add a full new domain.
59 if [[ $new_domain == *"."*"."* ]]; then
60 # add a subdomain to the containing domain.
61 add_new_subdomain "$new_domain"
64 # create a totally new domain in DNS.
65 write_new_domain_file "$new_domain"
66 add_zone_for_new_domain "$new_domain"