#!/bin/sh # Author: Khalid Baheyeldin http://2bits.com # Based on Artisan Numerique http://artisan.karma-lab.net/node/1240 # TMP=/tmp PROG=`basename $0` if [ $# != 3 ]; then echo "Usage: $PROG old_version new_version drupal_directory\ne.g. $PROG 5.5 5.6 /var/www" exit fi VER_OLD=$1 VER_NEW=$2 DRUPAL_DIR=$3 # Change that to the directory where Drupal is installed PATCH_FILE=$TMP/drupal-$VER_OLD-to-$VER_NEW.patch cd $TMP rm -rf drupal-* for VER in $VER_OLD $VER_NEW do # Download the tar ball TAR_GZ=drupal-$VER.tar.gz wget http://ftp.drupal.org/files/projects/$TAR_GZ if [ -r $TAR_GZ ]; then # Extract it tar -xzf $TAR_GZ if [ $? != 0 ]; then echo "Could not extract $TAR_GZ" exit fi else echo "Could not download $TAR_GZ" exit fi done # Now create the diff file diff -Naur drupal-$VER_OLD drupal-$VER_NEW > $PATCH_FILE # Now change to the directory where your Drupal installation is cd $DRUPAL_DIR # Check that the patch would apply without errors patch -p1 --dry-run < $PATCH_FILE # Assuming there are no error from the previous step, you can echo "Please review the messages above, then answer the following question!" # now apply the patch for real echo "Do you want to proceed with the patch? (y/n) \c" read ANS case $ANS in y) echo "Applying patch ..." patch -p1 -b < $PATCH_FILE ;; *) echo "Patching cancelled ..." ;; esac