Last weekend our dev team attended the Pacific Northwest Drupal Summit. We had a blast, we nerded out about Foundation and we learned a lot (especially about SCSS and Compass). We were taking furious notes and we can expect some big changes to come to our Cogito Foundation theme in the coming weeks.
We also did a presentation where we took a website from design to build to theming to launch in front of a live audience in 45 minutes. People said we were crazy (and the jury is still out on that one) but it worked like a charm and the demo gods were with us.
One of the things we demonstrated was how to use a .make file with 'drush make'. Drush make goes out and pulls in all the modules, themes and features you need to set up a site. Once drush make is finished you have to do a regular site install, enable your themes and plugins etc.
I was watching Colin present this and I thought to myself " This is awesome but there myst be a way to automate all the fiddly bits you need to do after your make file runs."
So we went to work and came up with the following script, annotated using Gist and Zurb's Chop App for your convenience
Commented using Zurb's chop app. http://chopapp.com/#b9ihtok3
There's nothing magic or super innovative here. All the pieces have been available to us for quite some time but when we assemble them all together in a script we get a significant time savings on iterative builds of a site.
Ok, so what does this script do:
- You fill out your site details, modules, features you want to enable etc. at the top of the file.
- It then runs 'drush make' on the make file you specify
- Then it does a drupal install with the credentials you specify
- Turn on the modules we care about, turn off the modules we don't care about
- Create a new cogito subtheme and change its name to match our site.
- Enable features and themes (including our new child theme)
- run cron
- clear the cache
A better way
As it turns out drush has all kinds of goodness to do things automatically and make our lives better. One of the little known things about it is that you can use it inside a shebang script with PHP.
here are a couple of resources to outline how that works:
- A little documentation on getting started: http://drush.ws/docs/shellscripts.html
- A drupal issue with some common parameter qurestions: http://drupal.org/node/926780
- Awesome step-by-step guide to creating a backup script: http://louis-sawtell.com/content/create-drush-shell-script-backup-update...
- An example script: http://drush.ws/examples/helloworld.script
drush site-install?!? NO WAY!!!!
This is a big discovery for us because when we're iterating through our builds we end up doing a lot of installs every day. Now with one drush command we can enter all our admin user details, our database credentials and perform a standard site install.
Take a look at line 51 of the script to see it in action.
We just started with these drush shell scripts so if you've been using them for a while and do really neat things we'd love to hear from you.