#!/bin/bash ### upgrade-wp - updates installed WP sites from list to new version ### Originally it just: cd $DOMAIN; copy in new files, chown them over, click links. ### Now variablized to support most setups, but public_html style additional ### folders in the path would require more complex logic. ### copyleft adric@adric.net 2008 Artistic License ### Edit these for the server before running web_user=christal web_home=/web/sites/ ## Desired version of WP target_version="2.5.1" ## list of wordpress domains, one per line wp_sites=wp_sites ## this is actually just tilde on a standard install: tilde=/web/sites/sysadmin ###check for the input file and die if not found if ! [ -x "$wp_sites" ] then echo "uwp: WP sites file $wp_sites not found. nothing to do." && exit ## syntax for -1 ? fi ###check to see if we have the wp files local already, and if not, grab them ### and put them in a specific place. Logic: If the file exists in the ### wpu directory, we've run before here and can proceed, else, set it all up. ### If this is somehow a concern you could add a cookie string to wpu and ### match for that. ## check ~/uwp for wordpress-$target_version.tar.gz ## if not, make the folder, get it and untar it if ! [ -x "$tilde/wpu/wordpress-$target_version.tar.gz" ] then mkdir $tilde/uwp/; cd $tilde/uwp ## wget -q ? wget -q http://wordpress.org/latest.tar.gz tar zxf wordpress-$target_version.tar.gz || echo "uwp: Untar failed!" && exit fi ### the main upgrade loop for domain in `cat wp-sites` do # echo -n "uwp: $domain upgrading ... " cd $web_home/$web_user/$domain cp -r $tilde/uwp/wordpress/* . chown -R $web_user:www-data * # have WP do all the work for us, thanks! curl -q is quiet? curl -q http://www.$domain/wp-admin/ > /dev/null curl -q http://www.$domain/wp-admin/upgrade.php?step=1&backto=%2Fwp-admin%2F > /dev/null echo "$domain upgraded." done