#!/bin/sh
#
# Drupal module updater.
# Written by Raul Santos, a.k.a. borfast
# http://borfast.com
#
# Use this script by passing it the URL of the updated module as a parameter.
# Example:
#    sh update_modules.sh http://ftp.drupal.org/files/projects/spam-5.x-3.x-dev.tar.gz
#
# This work is licensed under a
# Creative Commons Attribution-Share Alike 3.0 Unported License:
# http://creativecommons.org/licenses/by-sa/3.0/
#
#

url=$1
filename=${url##*/}
module=${filename%%-*}
echo "Downloading module '$module' from $url"
wget $url

echo "Removing old module directory..."
rm -rf $module

echo "Decompressing module from $filename..."
tar xfz $filename

echo "Setting the correct permissions..."
chmod -R a+rX $module

echo "Removing downloaded package '$filename'..."
rm -rf $filename


echo "All done. If there aren't any error messages above, your module should now be updated."
