image/svg+xml Openclipart 2007-11-20T10:29:44 Some shapes from photos. Chrisdesign clip art clipart image media nature png public domain shape silhouette svg tree


Drush, a King Among Men

16 Mar 2009

Drush is wonderful. I discovered it about six to nine months ago and can’t even fathom the amount of time it has saved me. Thank you, Drush, more specifically the wonderful developers on the project.

Drush Basics

If you are not in the know, and it’s okay if you are not, Drush is a command line application for Drupal. Drush by itself is more of a framework, and becomes much more powerful and useful in conjunction with Drush Extras. Once you have set things up, you can do something like:

drush pm install cck views imagecache

This would install (cvs checkout to sites/all/modules) the CCK, Views, and ImageCache modules. You would still have to go to the web administration to enable the modules. But, how easy is that! I am starting to put put together Drush install profiles, instead of using Drupal’s install profiles. (I understand that these are two very different utilities) For instance, I have put together this single command that will checkout all the latest versions of my usual modules for site:

drush -l pm install admin_menu advanced_help better_formats calendar cck date devel favicon filefield globalredirect gmap google_analytics imageapi imagecache imagecache_actions imagefield jquery_update lightbox2 link location logintoboggan markdown mollom pathauto token views seo_checklist context spaces cvs_deploy coder nodequeue wysiwyg webform xmlsitemap emfield jq jquery_media content_profile twitter flickr job_queue

And then, I can review and update them all via the following command.

drush -l pm update

You still have to visit update.php and, with any contributed module, make sure it doesn’t break your site.

Recent Drush Presentation

At DrupalCon DC just a couple weeks back, Moshe Weitzman and Owen Barton did the presentation: Drush, Command Line Drupal Productivity. Watch the video

Simple Script to Help Setup Drush

Since the only slight problem with Drush is setting up, which has gotten much easier in the the new 2.x branch, I have created a simple shell script to help automate it. I am not that experienced with shell scripting, but this works in my environment and is a good place to start otherwise.




# General variables


# Check directory

if \[ -d $DRUSHPATH \]; then
  echo "Drush directory exists.";
  echo "Creating drush directory.";
  mkdir $DRUSHPATH;

# Go to drush dir

echo "Going to drush directory.";

# Get drush

echo "Download and untar drush.";
tar -zxvf drush-*;

# Get drush_extras

echo "Download and untar drush_extras.";
tar -zxvf drush_extras-*;

# Make a handy alias

echo "Make alias in: $ALIASFILE";
echo "# Drush alias auto added" >> $ALIASFILE;
echo "alias $DRUSHALIAS='php $DRUSHPATH/drush/drush.php'" >> $ALIASFILE;
echo "You may have to restart your shell session for the alias to take effect.";
  Drupal Basics and Best Practices
Drupal Sites and Security