projects
/
feisty_meow.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cleaning up logging
[feisty_meow.git]
/
scripts
/
system
/
add_domain.sh
diff --git
a/scripts/system/add_domain.sh
b/scripts/system/add_domain.sh
index df4f5ea5656cadcfa7804f5ba5dba4a633b45c19..80ebb2f37d0563e6d0d9b0d768d1e9b80a0797c3 100644
(file)
--- a/
scripts/system/add_domain.sh
+++ b/
scripts/system/add_domain.sh
@@
-8,13
+8,19
@@
#
# Author: Chris Koeritz
#
# Author: Chris Koeritz
+export WORKDIR="$( \cd "$(\dirname "$0")" && \pwd )" # obtain the script's working directory.
+export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+
+source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
+
# some defaults that are convenient for current purposes.
# some defaults that are convenient for current purposes.
-# hmmm: these would need to be parameterized somehow for this script to become really general.
+
+# 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.
# 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"
+SERVER_ADMIN="
developer
.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).
# 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).
@@
-33,10
+39,12
@@
function write_new_domain_file()
echo "using the config file: $domain_file"
if [ -f $domain_file ]; then
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 "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 "data in it, we will just leave it in place and consider our job done."
+ echo
exit 0
fi
exit 0
fi
@@
-55,6
+63,10
@@
function write_new_domain_file()
${domain_name}. IN A ${IP_ADDRESS}
IN HINFO \"linux server\" \"${DISTRO}\"
" >"$domain_file"
${domain_name}. IN A ${IP_ADDRESS}
IN HINFO \"linux server\" \"${DISTRO}\"
" >"$domain_file"
+
+ # our personalized configuration approach wants the real owner to own the file.
+ chown "$(logname):$(logname)" $domain_file
+ test_or_die "setting ownership on: $domain_file"
}
# hooks up a new config file into bind's list of zones.
}
# hooks up a new config file into bind's list of zones.
@@
-78,6
+90,11
@@
zone \"${domain_name}\" in {
////////////////////////////////////////////////////////////////////////////
" >> /etc/bind/named.conf.local
////////////////////////////////////////////////////////////////////////////
" >> /etc/bind/named.conf.local
+
+ # keep ownership for the real user.
+ chown "$(logname):$(logname)" /etc/bind/named.conf.local
+ test_or_die "setting ownership on: /etc/bind/named.conf.local"
+
}
# adds a new subdomain under a containing domain.
}
# adds a new subdomain under a containing domain.
@@
-115,6
+132,9
@@
${subdomain}.${containing_domain}. IN A ${IP_ADDRESS}
IN HINFO \"linux server\" \"${DISTRO}\"
" >> /etc/bind/${containing_domain}.conf
IN HINFO \"linux server\" \"${DISTRO}\"
" >> /etc/bind/${containing_domain}.conf
+ # keep ownership for real user.
+ chown "$(logname):$(logname)" "/etc/bind/${containing_domain}.conf"
+ test_or_die "setting ownership on: /etc/bind/${containing_domain}.conf"
}
function restart_bind()
}
function restart_bind()
@@
-130,7
+150,7
@@
function restart_bind()
# main body of script.
# 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
echo "This script must be run as root or sudo."
exit 1
fi