Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# CREATE BACKUPS BEFORE RUNNING THIS SCRIPT!
for m in $(locate Mage.php | grep -v downloader); do
cd $(dirname $(dirname $m)) || (echo && continue) # old locate db
MAGE_VERSION=$(php -d error_reporting=0 -r "require 'app/Mage.php'; Mage::app(); echo Mage::getVersion();")
if echo $MAGE_VERSION | egrep -q "^[0-9.]+$"; then
if [ $MAGE_VERSION "<" 1.4.0.0 ] || [ $MAGE_VERSION ">" 1.7.0.1 ]; then
echo -e "No patch available for version $MAGE_VERSION in $(pwd)\n"
continue
elif [ $MAGE_VERSION "<" 1.4.2.0 ]; then
URL=http://www.magentocommerce.com/downloads/assets/1.7.0.2/CE_1.4.0.0-1.4.1.1.patch
elif [ $MAGE_VERSION "<" 1.5.0.0 ]; then
URL=http://www.magentocommerce.com/downloads/assets/1.7.0.2/CE_1.4.2.0.patch
else
URL=http://www.magentocommerce.com/downloads/assets/1.7.0.2/CE_1.5.0.0-1.7.0.1.patch
fi
echo Patching Magento $MAGE_VERSION in $(pwd)
echo using patch $URL
#### Remove --dry-run AT YOUR OWN RISK! ####
curl -sS $URL | patch -p0 --dry-run
echo
else
echo -e "Unable to determine Magento version in $m\n"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.