#!/bin/sh # Batch-update WordPress installations that have been checked out via subversion # (see: http://codex.wordpress.org/Installing/Updating_WordPress_with_Subversion) # Iterate over array of installations and split vars into components: # path|URL|email|owner # CD to path, run svn sw [to latest tag release] # Send email notifying blog owner # Current version and tag URL, to which all blogs will be upgraded echo echo -n "WordPress version? "; read ver wptagurl="http://svn.automattic.com/wordpress/tags/$ver/" echo -n "Upgrading all blogs to version $ver. Is this correct? (y/n) " read answer if [ $answer != "y" ]; then echo "Halting. Try again." exit fi # Array of sites under svn control. Holes in array numbering are fine, duplicates not. # format: fullpath|URL|email site[1]="/home/joe/public_html/joeslife|somesite.org/joeslife|joe@somedomain.org|joe" site[2]="/Library/WebServer/Documents/wwwroot/blog|somedomain.edu/blog|owner@somedomain.edu|admin" site[3]="/home/amy/public_html|photographs.com|amy@photographs.com|amy" # .... as many as you like echo "Upgrading blogs to $ver" echo # Iterate through array, upgrading each for blog in ${site[@]} do #echo $blog dir=$(echo $blog | cut -f1 -d\|) url=$(echo $blog | cut -f2 -d\|) email=$(echo $blog | cut -f3 -d\|) owner=$(echo $blog | cut -f4 -d\|) echo "Upgrading WordPress installation:" echo "Dir: $dir" echo "URL: $url" echo "E-mail: $email" echo cd $dir /usr/bin/svn sw $wptagurl . echo echo "If no errors shown above, upgrade successful." echo "Fixing permissions..." chown -R $owner:$owner * chown -R $owner:nobody wp-content echo echo "If no errors shown above, upgrade successful." echo curl -o /dev/null "http://$url/wp-admin/upgrade.php?step=1&backto=" # Send announcement email msgtext=" Hi - Your WordPress blog at http://$url has been upgraded by [this organization] to version $ver. Rapid upgrades of web applications are very important for security reasons, and often bring welcome feature changes. It's unlikely that this upgrade has had any negative effect, but occassionally 3rd party WordPress plugins will bork when WordPress is upgraded. If any new issues have cropped up with your blog, please contact us. " echo "$msgtext" | /bin/mail -s "Your WordPress installation has been updated" $email echo echo "Upgrade announcement email sent." echo "------------------------------------" echo done