Short shell script for speeding up getting Drupal modules

What follows is a short shell script I use for making it easier to get modules from the Drupal repository. It is best to use this script only with sources where you have a great deal of confidence in the source of the file you're downloading. Of course nothing substitutes for using good practices when it comes to deciding whether to install a program and its possible implications.

Read on for the code itself. It is a very simple script that makes it easy to copy the location of a file from a website and then download and uncompress the file. It could be much fancier but it does the trick.


if [ $# -ne 1 ]; then
         echo 1>&2 Usage: dget URL
         exit 127

curl $1 | tar xzv

To use this script on Mac OS X copy it into a text file. You then need to set permissions to make it executable. The easiest way to do this is:

chmod a+x dget

I'll write more about it tomorrow but this script comes in handy when you need to download more than 100 modules. There certainly are some other ways of using CVS and other tools but if one wants to look at the web page for modules and read the notes on each one this is an easy way to get around some extra typing.



another idea

what about:


set -e


if [ -z "$1" ]; then
  echo "usage: drupdown file"

wget $DOWN
tar -zxf $(basename $DOWN)
chown -R $GROUP $(echo $(basename $DOWN) | sed 's/-.*.gz//')
rm $(basename $DOWN)

echo "extracted in $(echo $(basename $DOWN) | sed 's/-.*.gz//')"

or CVS?

To get a module from CVS is pretty easy once you understand how... Eg:

cvs -z4 co -d example -r DRUPAL-5--1-0 contributions/modules/example

The hardest thing I find about using CVS in this case is knowing the revision number to use, but once you now that then its much easier in the future to updgrade. Say you checkout DRUPAL-5 which is a dev branch then you can easily do cvs up -dP to checkout the latest version of that module without having to worry about getting the paths, etc again.

I use wget for downloading

I use wget for downloading from a shell. It's a great tool with features such as continuing a stopped transfer, read download urls from a file, recursive download, etc.

I prefer cvs and so I have

I prefer cvs and so I have something similar:

# !/bin/bash
# dcvs
# does a cvs checkout of the given contributed module/theme

if [ $# -ne 3 ]
         echo 1>&2 Usage: dcvs modules/MODULE_NAME VERSION DIRECTORY_TO_PUT_IN
         echo 1>&2 or___: dcvs themes/THEME_NAME VERSION DIRECTORY_TO_PUT_IN
         exit 127

cvs -z6 checkout -d $3 -r $2 contributions/$1

What about drush?

I you haven't looked at it yet I highly reccomend it. Among other things it has a package manager that makes installing a module as easy as typing

drush pm install cck views panels

It looks up the latest stable version, and (it the -dev drush) can use your choice of cvs, wget or curl to download the package. It can also update any/all modules from the command line (again using the update system backend). More features are on the way too!

see drush module

drush module does this, and about 50 more. please help make it better. it is the command line for drupal.

Delete directories

My understanding is that we should be deleting old directories first when upgrading modules.

I want a script that:

* iterates over all *.tar.gz files

** greps out the directory name

** deletes (or maybe backs up) the directory, if it exists

** untars the file

** deletes the tar file

Then I can just download all the modules I want to install or update, run the one script, and then do the update.php when appropriate.

here's a start:

for i in `ls *.tar.gz`; do
  tar -zxf $i

Drush is certainly on my list to check out

I just heard about Drush last week and it's on my list. Awesome to hear it has the package manager. I'll be moving it up the list of things to check out! (or given that I already have it checked out... ok no CVS humor)...

DRUpal SHell

Have you folks heard of drush? It includes a "package manager" for Drupal from the command line. The one disadvantage is that it needs a running Drupal site, but it's still the way to go I think.

benjamin, Agaric Design Collective

CVS is what you want

CVS is what you want if you want to checkout files and then be able to update them as newer versions are released. CVS has many more capabilities but it can do what you're looking for rsync capability. There's a really pretty good handbook section on CVS at

Shell script with drush commands

Go to for the ability to automatically generate shell scripts to download a list of drupal modules via drush