[Hcoop-discuss] Add Domain Tool

rob at hcoop.net rob at hcoop.net
Wed Oct 5 17:01:35 EDT 2005


I wrote a bash script to setup, configure, and localize all the dns and
www files used by domtool and apache.  I think it makes it a lot easier to
deal with my domains when everything accessible in my home directory -- A
lot less for me to type out and remember thats for sure.   Basically what
it does is, setups new domains with a default www and dns file.  Then it
creates a bunch of symbolic links to useful files like dns config, www
config, and apache logs.  It also creates creates an htdocs, cgi-bin dir
and appends a dns entry to the parent domain if the domain you are trying
to add is a subdomain.  After all this it runs domtool.

Bash probably isn't the best language for this but this script turned out
to be a little more involved than I thought it was going to be.  Also, it
works OK for me but thats not to say it isn't bug free.  In anycase, if
this is useful for anyone else here ya go!  Hopefully someone hasn't
already written a tool to do this otherwise I wasted a good 4 hours.

-Rob


------

EXAMPLE: New domain setup

$ adddom gatherings.digitalgeek.net
No DNS config file found for gatherings.digitalgeek.net. Create it? [y/n]: y
Directory, /etc/domains/net/digitalgeek/gatherings/, does not exist.
Creating...
Append DNS entry "Alias  gatherings  www" to
/etc/domains/net/digitalgeek/.dns? [y/n]: y
Creating symlink /home/rob/domains/dns/gatherings.digitalgeek.net ->
/etc/domains/net/digitalgeek/gatherings/.dns...
No WWW config found for gatherings.digitalgeek.net. Create it? [y/n]: y
Create WWW associations? [y/n]: y
Creating local WWW directory,
/home/rob/domains/www/gatherings.digitalgeek.net...
Creating symlink
/home/rob/domains/www/gatherings.digitalgeek.net/http.conf ->
/etc/domains/net/digitalgeek/gatherings/www...
Creating symlink /home/rob/domains/www/gatherings.digitalgeek.net/logs ->
/var/log/apache2/www.gatherings.digitalgeek.net...
Creating cgi-bin directory...
Creating htdocs directory...

<snip> domtool output here </snip>

------

EXAMPLE: Existing domain setup

$ adddom amber.digitalgeek.net
Replace DNS config /etc/domains/net/digitalgeek/amber/.dns with
/home/rob/domains/default_dns? [y/n]: n
Creating symlink /home/rob/domains/dns/amber.digitalgeek.net ->
/etc/domains/net/digitalgeek/amber/.dns...
Replace WWW config /etc/domains/net/digitalgeek/amber/www with
/home/rob/domains/default_www? [y/n]: n
Create WWW associations? [y/n]: y
Creating symlink /home/rob/domains/www/amber.digitalgeek.net/http.conf ->
/etc/domains/net/digitalgeek/amber/www...
Creating symlink /home/rob/domains/www/amber.digitalgeek.net/logs ->
/var/log/apache2/www.amber.digitalgeek.net...
Processing complete.

------

LOCAL DIR STRUCTURE:

 ~/domains/dns/
   amber.digitalgeek.net@        - symlink to real config file
   gatherings.digitalgeek.net@   - symlink to real config file

 ~/domains/www/amber.digitalgeek.net/
   http.conf@                    - symlink to real config file
   logs@                         - symlink to real config file
   htdocs/
   cgi-bin/

 ~/domains/www/gatherings.digitalgeek.net/
   http.conf@                    - symlink to real config file
   logs@                         - symlink to real config file
   htdocs/
   cgi-bin/


------

FILE: ~/.adddom

domtool_dir = /etc/domains

my_dns_dir = ~/domains/dns
my_www_dir = ~/domains/www

default_dns_file = ~/domains/default_dns
default_www_file = ~/domains/default_www

------

FILE: ~/domains/default_dns

Slave abu

Primary         ns      ns
Secondary       ns1     ns2
Secondary       ns2     denim

Mail            mail    mail

Default         this

Alias           www     www

------

FILE: ~/domains/default_www

Default

User rob
Group rob

ServerAdmin webmaster at digitalgeek.net
DocumentRoot /home/rob/domains/www/[DOMAIN]/htdocs

CGI /home/rob/domains/www/[DOMAIN]/cgi-bin
ScriptAlias /cgi-bin/ /home/rob/domains/www/[DOMAIN]/cgi-bin/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: adddom.sh
Type: application/octet-stream
Size: 8562 bytes
Desc: not available
Url : http://lists.hcoop.net/pipermail/hcoop-discuss/attachments/20051005/94b43fe8/attachment.obj 


More information about the HCoop-Discuss mailing list