Posts Tagged updates

Forever Updating

I find little time these days and I noticed with some annoyance that I was behind with my WordPress updates. I run a number of sites (13 WordPress sites alone) and updating from 2.5 -> 2.5.1 is sort of painful and tedious.

So I made a script (most of the domain names are removed but you could add to the list):

sites=(illusoryfollies.com
       flanaganclan.com
       sarahflanagan.com)
 
base_path="/var/www/vhosts"
wordpress_download_url="http://wordpress.org/latest.tar.gz"
wordpress_download_file="latest.tar.gz"
wordpress_download_directory="wordpress"
wordpress_database_update_url="wp-admin/upgrade.php?step=1&backto=%2Fwp-admin%2F"
jailed_directory="httpdocs"
temp_directory="wp-temp"
 
number_of_sites=${#sites[@]}
 
 
echo "Updating $number_of_sites websites with the latest version of Wordpress."
 
for current_site in ${sites[@]}
do
  echo "Now processing $current_site..."
  echo "  Setting up directories..."
  if [ -e $base_path/$current_site/$jailed_directory ]
  then
    echo "  !!Detected a jail'ed website..."
    mkdir -p $base_path/$current_site/$jailed_directory/$temp_directory
    cd $base_path/$current_site/$jailed_directory/$temp_directory
  else
    mkdir -p $base_path/$current_site/$temp_directory
    cd $base_path/$current_site/$temp_directory
  fi
 
  echo "  Downloading latest version of Wordpress..."
  wget -q $wordpress_download_url
  echo "  Uncompressing..."
  tar zxfv $wordpress_download_file > /dev/null
  cd $wordpress_download_directory
  echo "  Copying into existing directory..."
  cp -r * ../..
  cd ../..
  echo "  Updating database..."
  wget -q "http://$current_site/$wordpress_database_update_url" -O /dev/null
  echo "  Cleaning up..."
  rm -rf $temp_directory
  echo "Done processing $current_site."
  echo ""
 
done

Now it takes about 15 seconds to update everyone’s site and it even performs the “Database Upgrade” step (at least for now).

Automation is a good thing. Speaking of which, I’m interested in Capistrano but I still haven’t really done anything with it. It looks like fun… I’ll have to add a post if I have any luck experimenting with it.

, , , ,

No Comments