There are some very trivial administration tasks that I find myself doing over and over again in Drupal which can’t currently be done from the admin interface. As of right now, these include installing a theme or module from drupal.org or adding a new site to an existing Drupal install. So, I’ve built a tiny Capistrano file that allows me to automate these tasks.

The tasks that I’ve setup are:

cap drupal:install:theme
cap drupal:install:module
cap drupal:install:site

cap drupal:install:theme

All this task requires is a path to the tar file of the theme that you want to install. What I do is browse over to the list of Drupal themes, find one that I want to try out, and copy the location of the “Download” link for the correct theme. In Firefox and Safari its as simple as right clicking the link and selecting “Copy Link Location”. Make sure the version of the theme corresponds to the version of Drupal you have installed.

Once you’ve got the location to your theme copied, run the task with cap drupal:install:theme. It will ask you for the path to the theme location which you can then paste in. That’s it. You should be able to browse to admin/build/themes and see your newly installed theme.

Currently this task assumes that you want all your themes to be downloaded in /var/www/drupal/sites/all/themes/. This is very easy to change in the capfile.

cap drupal:install:module

This is very similar to theme installation task and it just requires the path to the module you want installed. Again, browse to the list of modules find the one you want installed, copy its tar location and enter in the prompt after you run cap drupal:install:module.

This also assumes you want all your modules to be downloaded into /var/www/drupal/sites/all/modules. Another easy change.

cap drupal:install:site

This task creates a new site and its database from parameters you can specify. It creates the necessary folder in the sites directory and creates the settings file with the correct database name, username, and password. One thing you might want to change here is my use of mysqli vs. mysql.

Besides the ones listed above, the other big assumption I make is that you have curl installed (an easy apt-get install curl in Debian). I’m using curl to grab the tar files from Drupal.org. I could have easily used wget, but I like curl better. Just a preference that you can easily change in the file if you don’t like it.

There you have it. Now installing a theme, module, or new site is only a cap drupal:install away.