Skip to content

Instantly share code, notes, and snippets.

@nacin
Created January 31, 2013 19:37
Show Gist options
  • Save nacin/4685718 to your computer and use it in GitHub Desktop.
Save nacin/4685718 to your computer and use it in GitHub Desktop.
Update WordPress with a dirty bash script. (Please use version control, not this...)
#!/bin/sh
WEBROOT=/var/www/wordpress
LATEST_VER=$(curl -s http://api.wordpress.org/core/version-check/1.5/ | head -n 4 | tail -n 1)
LOCAL_VER=$(grep wp_version\ = $WEBROOT/wordpress/wp-includes/version.php | grep -o "'.*'" | sed -e "s/'//g")
echo "Latest version of WordPress: $LATEST_VER"
echo "Version on $(uname -n): $LOCAL_VER"
if [ "$LATEST_VER" == "$LOCAL_VER" ]; then
echo "No need to update.";
elif [ "update" == "$1" ]; then
rm -f latest.zip
wget http://wordpress.org/latest.zip
unzip -q latest.zip
mv wordpress $WEBROOT/wordpress-new
mv $WEBROOT/wordpress $WEBROOT/wordpress-old
mv $WEBROOT/wordpress-new $WEBROOT/wordpress
rm -f latest.zip
rm -rf $WEBROOT/wordpress-old
echo "$WEBROOT updated to $(grep wp_version\ = $WEBROOT/wordpress/wp-includes/version.php | grep -o "'.*'" | sed -e "s/'//g")"
else
echo "Run '!! update' to update $WEBROOT";
fi
#!/bin/sh
WEBROOT=/var/www/wordpress
LATEST_VER=$(curl -s http://api.wordpress.org/core/version-check/1.5/ | head -n 4 | tail -n 1)
LOCAL_VER=$(grep wp_version\ = $WEBROOT/wordpress/wp-includes/version.php | grep -o "'.*'" | sed -e "s/'//g")
if [ "$LATEST_VER" != "$LOCAL_VER" ]; then
echo "$(uname -n) is running an out-of-date WordPress version."
echo "Latest version of WordPress: $LATEST_VER"
echo "Version on $(uname -n): $LOCAL_VER"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment