Automating Development Website Setup
Sean Brown | Monday, May 22, 2006
- The tool should be interactive, rather than configuration-driven.
- The tool should enforce naming policies our company had put in place.
- The tool should integrate with Subversion, our chosen source control system.
- To help cut down on misconfiguration caused by typos, some sane defaults should be presented.
- The tool should automate the setup of both PHP-based and Rails-based applications.
- The tool should make developers' lives easier by pre-populating dev sites with Barefoot standard code libraries. Once the site has been prepopulated, a new Subversion entry is created for the new site.
Overview of what the script does, in the order it does it:
- Ask the user to enter a new hostname, check it against or naming policies using regular expressions. Fail with useful error if needed.
- Ask the user to enter the domain name, give the user a sane default (thinkbarefoot.com), and check it using regular expressions. We separate the hostname and the domain name becuase Barefoot's standard directory structure for Apache-based sites is
/www/domainname/host.domainname. Whenever we say we're giving a "sane default" we mean that the user can simply hit the enter key to select it.
- Choose an FTP username and password for the dev site. GSD, FWUEIN (give sane default, fail with useful error if needed).
- Choose a Subversion repository name. Check it against our naming convention. GSD, FWUEIN.
- Choose either a Rails-based project or PHP-based.
- We have a "skeleton" directory for each of the two development types. Depending which one is chosen, we create a new user, make that user's home directory be the result of #2 above, and populate that home directory with the contents of the correct skeleton directory.
- Add a new virtual host to the Apache configuration. The correct entries are put in place for each of the two project types. This is done using sed to take a template file we've created for each and replacing the info gathered above.
- Next, we check out our standard librabries from Subversion and place them in appropriate places in the new directory structure.
- Now that the new site is put together, we wrap it all up into the Barefoot standard directory structure for Subversion, and check the new module into our Subversion server. Keen observers will note that we use the password-less authentication for SSH discussed in our blog here.
- Finally, we set the correct ownership on the files and clean up some extraneous directories made simply to make a nice Subversion module.
- As the script exits, it reminds the user to add the new host to our internal DNS and spits out the login information for easy copy and paste into your preferred login notes.