#!/bin/bash desc="Update Drupal module to a given version" usage="$0 [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