Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Automated WordPress upgrades using SVN tags
#!/bin/bash
TAGSURL='http://core.svn.wordpress.org/tags/'
STABLETAG=`curl -s $TAGSURL | awk -F '">' '{print $2}' | awk -F"/<" '{print $1}' | egrep "^[0-9].[0-9]" | sort -n | tail -n 1`
if [ $STABLETAG == '' ]
then
echo "Stable tag not found, exiting..."
exit 1
fi
for ADDON in `ls -1d /home/user/sites/*/`
do
if [ -e $ADDON/wp-load.php ] && [ "`svn info $ADDON | grep tags`" ]
then
echo "Upgrading $ADDON to $STABLETAG..."
cd $ADDON
svn sw $TAGSURL$STABLETAG
svn up
WPCONFIG='wp-config.php'
DB_HOST=`sed -n "s/.*\(['\"]\)DB_HOST\1[ \t]*,[ \t]*\(['\"]\)\(.*\)\2[ \t]*);.*/\3/p" $WPCONFIG`
DB_NAME=`sed -n "s/.*\(['\"]\)DB_NAME\1[ \t]*,[ \t]*\(['\"]\)\(.*\)\2[ \t]*);.*/\3/p" $WPCONFIG`
DB_USER=`sed -n "s/.*\(['\"]\)DB_USER\1[ \t]*,[ \t]*\(['\"]\)\(.*\)\2[ \t]*);.*/\3/p" $WPCONFIG`
DB_PASSWORD=`sed -n "s/.*\(['\"]\)DB_PASSWORD\1[ \t]*,[ \t]*\(['\"]\)\(.*\)\2[ \t]*);.*/\3/p" $WPCONFIG`
TABLE_PREFIX=`sed -n "s/.table_prefix[ \t]*=[ \t]*\(['\"]\)\(.*\)\1[ \t]*;.*/\2/p" $WPCONFIG`
SITEURL=`mysql -h "$DBHOST" -u "$DB_USER" -p"$DB_PASSWORD" "$DB_NAME" --batch -sre "SELECT option_value FROM ${TABLE_PREFIX}options WHERE option_name='siteurl'"`
RESPONSE=`curl -siL "$SITEURL/wp-admin/upgrade.php?step=upgrade_db"`
CODE=`echo "$RESPONSE" | head -1 | awk '{print $2}'`
if [ "$CODE" != "200" ]
then
echo "Failed to update $SITEURL: $CODE"
exit 1
fi
fi
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.