Barefoot Development

Automating Development Website Setup

Over the years, setting up development and staging environments for our websites had become a tiresome chore, filled with "opportunities" for typos. So one Saturday evening, I sat down, brushed the dust off my bash scripting skills and wrote a handy little tool for Barefoot. I know that there are other tools out there, but I found none that acomplished all of our goals:
  1. The tool should be interactive, rather than configuration-driven.
  2. The tool should enforce naming policies our company had put in place.
  3. The tool should integrate with Subversion, our chosen source control system.
  4. To help cut down on misconfiguration caused by typos, some sane defaults should be presented.
  5. The tool should automate the setup of both PHP-based and Rails-based applications.
  6. 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.
I think that's probably enough to ask of any tool. The script is far too long to go through every line, so I'll just give an overview here, and then make the entire script available for download. It's pretty well commented.

Overview of what the script does, in the order it does it:
  1. Ask the user to enter a new hostname, check it against or naming policies using regular expressions. Fail with useful error if needed.
  2. Ask the user to enter the domain name, give the user a sane default (, 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.
  3. Choose an FTP username and password for the dev site. GSD, FWUEIN (give sane default, fail with useful error if needed).
  4. Choose a Subversion repository name. Check it against our naming convention. GSD, FWUEIN.
  5. Choose either a Rails-based project or PHP-based.
  6. 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.
  7. 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.
  8. Next, we check out our standard librabries from Subversion and place them in appropriate places in the new directory structure.
  9. 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.
  10. Finally, we set the correct ownership on the files and clean up some extraneous directories made simply to make a nice Subversion module.
  11. 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.
While this hasn't revolutionized our lives, it has certainly cut down on the time spent setting up new development sites. By using a couple of choice templates, skeleton directories, and Subversion we've been able to keep our setup much more consistent.


Post a Comment

« Home