Here is a bash script for updating a Drupal module to a given version and archiving it (in case reversion is needed)
Note that if you are checking out a module, rather than Drupal core, the name of the module will be appended to the path where it is to be put. Also note that this script assumes that the Drupal core tree can be deleted, i.e. the sites directory within the tree is not used. I would strongly recommend that the actual website be in a different directory and symlink into the drupal tree, for easy updating. For information on how to do this, look here
#Paths to Drupal core files and contrib modules
#Modify the next three lines to suit your configuration
drupaldir=/var/www/drupal
targetdir=/var/www/modules
archivedir=/var/www/archive
#!/bin/bash
desc="Update Drupal module to a given version"
usage="$0 <name_of_module> <version> [alternative install path]"
source drupalpath.sh
ftpdir=http://ftp.drupal.org/files/projects/
if [ $# -lt 2 ]; then
if [ "$1" != "--help" ]; then
echo " ** wrong number of arguments supplied **"
fi
echo " " $desc
echo " Usage:" $usage
exit
fi
if [ -n "$3" ]; then # alternative install directory
if [ "$1" == "drupal" ]; then
drupaldir=$3
else
targetdir=$3
fi
fi
echo installing $1-$2 into $targetdir
wget -q $ftpdir/$1-$2.tar.gz
return_val=$?
if [ "$return_val" -ne 0 ]; then
echo "failed to wget $ftpdir/$1-$2.tar.gz"
exit
fi
rm -fR $targetdir/$1 #delete old version
chdate=`stat -c %y $1-$2.tar.gz | awk '{printf $1 "\n"}'`
tar -zxf $1-$2.tar.gz -C $targetdir
mv $1-$2.tar.gz $archivedir/$1-$2_$chdate.tar.gz
if [ "$1" == "drupal" ]; then
echo " Moving new version of drupal from:" $targetdir/$1-$2 to $drupaldir
rm -fR $drupaldir
mv $targetdir/$1-$2 $drupaldir
fi
Attachment | Size |
---|---|
update.txt | 1 KB |