#!/bin/bash # Make sure we're running through sudo export me=`whoami` if [ "$me" != 'root' ]; then echo "I don't like $me very much. Please run me via sudo."; exit -1; fi # Save some paths for reference export wpmu_base='/path/to/WPMU' export const="$wpmu_base/const" #Make sure we have something to do if [ "$1" == '' ]; then echo "Let's find out what we can do; downloading latest version..."; # Ideally, we'd fetch a text file with the latest version number before downloading. rm -f latest.zip curl -O http://mu.wordpress.org/latest.zip #List the files, finding our version number. export version=`unzip -l ./latest.zip | grep -E 'wordpress-mu-([0-9]*\.[0-9]*\.[0-9]*)' -m 1 -o` echo "$version downloaded..."; #Check to see if we already have it if [ -a $wpmu_base/$latest/ ]; then echo "... and you've already got it. Bye!"; exit -2; fi # Expand the latest version unzip ./latest.zip -d $wpmu_base; # Make a note of where it is export latest="$wpmu_base/$latest"; else echo "We'll be working with WPMU $1 today..."; # And make sure that the necessary WP download exists if [ -a ./wordpress-mu-$1.zip ]; then echo "... and I see that you were smart enough to download it."; # Expand latest WPMU version, version passed as command argument (eg $1) unzip ./wordpress-mu-$1.zip -d $wpmu_base/; # Make sure we note where it is export latest="$wpmu_base/wordpress-mu-$1"; else echo "... and it is nowhere to be seen! I cannot work under these conditions!"; exit -3; fi fi # Reset the owner on all of our new files chown -R administrator:admin $latest # Link wp-config file ln -fhs $const/wp-config.php $latest/wp-config.php # Link .htaccess file ln -fhs $const/.htaccess $latest/.htaccess # Link mu-plugins directory rm -R $latest/wp-content/mu-plugins ln -fhs $const/wp-content/mu-plugins $latest/wp-content/mu-plugins # Link plugins directory rm -R $latest/wp-content/plugins ln -fhs $const/wp-content/plugins $latest/wp-content/plugins # Link blogs.dir directory ln -fhs $const/wp-content/blogs.dir $latest/wp-content/blogs.dir # Link sunrise file ln -fhs $const/wp-content/sunrise.php $latest/wp-content/sunrise.php # Link each theme in themes folder for theme in `ls -d $const/wp-content/themes/*`; do echo "*** Copying theme from $theme" ln -fhs $theme $latest/wp-content/themes/ done # Link Gallery2 data folder ln -fhs $const/gallery2/ $latest/gallery2 # Link Gallery2 core folder ln -fhs $const/gallery2_core/ $latest/gallery2_core # Link WPMU version to current folder ln -fhs $latest/ $wpmu_base/current