Created
July 11, 2012 09:30
-
-
Save millejano/3089284 to your computer and use it in GitHub Desktop.
Patch all Magento versions according to the advisory http://www.magentocommerce.com/blog/comments/important-security-update-zend-platform-vulnerability/, using find instead of locate and a cd $OLDDIR for multiple installations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# CREATE BACKUPS BEFORE RUNNING THIS SCRIPT! | |
OLDDIR=$(pwd) | |
for m in $(find . -name "Mage.php" -not -path *var* -not -path *skin* -not -path *media* | grep -v downloader); do | |
cd $OLDDIR | |
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 | |
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