Last updated October 2, 2011. Created by trailerparkopera on October 21, 2008.
Edited by JuliaKM, eliza411, jaggedguru, bsmirnov. Log in to edit this page.
Note: drush is a command line shell and scripting interface for Drupal and includes an alternative, easier method for downloading and installing Drupal modules.
This article assumes that you have at least a basic understanding of how shell scripts work and that you know how to create one.
If you spend a lot of time installing, testing, uninstalling modules, sometimes you want to download and unpack modules from command line to automate process and make it faster. There are a couple of ways to do this, one is to use wget command to download the file and tar to unpack it, another way is to use cvs.
Below are 2 relatively simple bash scripts to help automate the installation process from the command line. There are some caveats to using shell scripts like these:
CAVEATS:
- Use it in directories that only store module subdirectories, and not an assortment of subdirectories and .tar and .gz files.
- There is no error trapping so if there's a problem, you'll have to figure it out yourself. But it's a simple script.
- Remember to change permissions on the script file to be able to launch the script (e.g. chmod ugo+x wgetarx.sh )
Solution 1: wget & tar
This will take any tarball (tar.gz) and download it and unpack it in your current directory.
in this example we are calling the script "wgetarx":
- Create a file (wgetarx.sh)
- put this in it
wgetarx#!/usr/bin/env bash
if [ -z "$1" ]
then
echo "USAGE: wgetarx <tarball-url>"
else
wget -O - $1 | tar zxv
fiNote:Alternatively if wget is not available (as it is on some hosts site5.com being one example) you can use curl instead like this:
#!/usr/bin/env bash
if [ -z "$1" ]
then
echo "USAGE: wgetarx <tarball-url>"
else
curl $1 | tar zxv
fi - Put it in your /usr/bin/ directory,
- Use chmod it to be executable. (chmod ugo+x wgetarx.sh )
- Go to your modules directory and invoke the script passing the url to it.
INSTRUCTIONS FOR USE:
1. Find a url for a module you want to download and unpack and copy it into clipboard
2. Go to the terminal and invoke the script with in the following way:
wgetarx http://ftp.drupal.org/files/projects/cck-6.x-2.1.tar.gz