One Step to download and unpack a module from the web
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
Solution 2: CVS Checkout Script
Another way to do it is to get CVS version of the module.
Ok so you got a module and want to make changes. In order to do a cvs diff you need to install the module from the CVS.
wgetcvs
#!/usr/bin/env bash
if [ -z "$2" ]
then
echo "USAGE: wgetcvs <module_name> <CVS-TAG>"
else
cvs -z6 -d:pserver:anonymous:anonymous@cvs.drupal.org:/cvs/drupal-contrib checkout -r $2 -d $1 contributions/modules/$1
fiPut this in your /usr/bin and chmod +x so it's executable
Usage Example:
Go to the project page
- http://drupal.org/project/cck
Go to the Dev Release page
- http://drupal.org/node/266142
Copy the CVS-TAG
- "DRUPAL-6--2"
Delete your current version of the module
- cd /sites/all/module
- rm -rf cck
wgetcvs the CVS version
- wgetcvs cck DRUPAL-6--2
