Aug 31

A friend of mine who is starting up his website hosting biz asked me how I update my Wordpress install. I told him I use a couple of bash scripts I made to update all Wordpress installs at once.
It seems to have helped him quite a bit, so I thought it might also help out somebody else.
#!/bin/bash
#
# Wordpress Update
#
# Requires: cpio, find, tar and wget
# By Guillermo Antonio Amaral Bastidas < gamaral@amaral.com.mx >
#
### CONFIGURE ###
declare WORDPRESS_LATEST='http://wordpress.org/latest.tar.gz'
declare TMP_DIR='/tmp'
## DO NOT MODIFY BELOW THIS LINE ##
export PATH='/bin:/usr/bin'
declare CPIO=`which cpio`
declare FIND=`which find`
declare RM=`which rm`
declare TAR=`which tar`
declare TEST=`which test`
declare WGET=`which wget`
declare COMMAND="${1}"
declare DESTINATION="${2}"
if [ -z "${COMMAND}" -o "${COMMAND}" = "HELP" ]; then
echo "Usage: ${0} [COMMAND] ([DESTINATION])"
echo " ${0} FETCH"
echo " ${0} UPDATE [PATH_TO_EXISTING_WORDPRESS_INSTALL]"
echo
exit 0;
elif [ "${COMMAND}" = "FETCH" ]; then
${WGET} -q -nv -O "${TMP_DIR}/wordpress.tar.gz" 'http://wordpress.org/latest.tar.gz'
${RM} -Rf "${TMP_DIR}/wordpress/"
${TAR} -xpszf "${TMP_DIR}/wordpress.tar.gz" -C"${TMP_DIR}"
elif [ "${COMMAND}" = "UPDATE" ]; then
if [ -z "${DESTINATION}" ]; then
echo "Usage: ${0} UPDATE [PATH_TO_EXISTING_WORDPRESS_INSTALL]"
echo
exit 1;
fi
${TEST} -d "${DESTINATION}";
if [ $? -ne 0 ]; then
echo "Destination directory does not exist."
echo "Abort"
echo
exit 2;
fi
${TEST} -d "${TMP_DIR}/wordpress/";
if [ $? -ne 0 ]; then
bash ${0} FETCH
if [ $? -ne 0 ]; then
echo 'Latest Wordpress Fetch Failed.'
echo 'Abort'
echo
exit 3;
fi
fi
( cd ${TMP_DIR}/wordpress/ && ${FIND} . | ${CPIO} -up --quiet "${DESTINATION}" )
if [ $? -ne 0 ]; then
echo 'Copy Failed'
echo
exit 1;
fi
fi
exit 0;
How it works:
$ update-wordpress.sh FETCH
Downloads and expands the latest release of Wordpress.$ update-wordpress.sh UPDATE PATH TO WORDPRESS INSTALL
Updates the specified Wordpress install.
Multiple Installs:
I use this tiny script to update multiple installs:
#!/bin/bash update-wordpress.sh FETCH update-wordpress.sh UPDATE /var/www/somesite.com/blog/htdocs update-wordpress.sh UPDATE /var/www/yoursite.org/www/htdocs
Cheers,
GA
Recent Comments