Updating many Joomla sites on server level
Simple shell script for Joomla hosting providers to update Joomla sites on their linux server
It is an ongoing task for Joomla site administrators to keep their sites secure with the latest version of Joomla. The normal procedure is to upload the zipped patch file into your Joomla root directory on your server, extract the patch file and the job is done.
If you are hosting several Joomla sites on your dedicated server/virtual dedicated server/cPanel reseller plan in a linux environment, you can easily automate this task for all sites on your server with a simple shell script.
The script below has two variables you need to set:
- The full path of your Joomla patch file. You need to upload this file onto your server first.
- The full path of all sites to be updated, separated by space.
The script will then change into the directories of the pathlist, unzip the patch file with the -o option (override and never prompt), write out a line with what file it unzipped in what directory and move on to the next directory until finished.
Copy the text below into a file with the extension .sh or download applyjoomlapatch.sh (590b).
To invoke the script type:
sh applyjoomlapatch.sh
#!/bin/sh
# This is applyjoomlapatch.sh
# WARNING! Use this only if you know what a shell is, and commands like pwd, ls,
# -lisa, sed, grep and awk.
# Use at own risk!
# enter the full path to your Joomla patch file
patch=/home/username/public_html/Joomla_1.5.25_to_1.5.26-Stable-Patch_Package.zip
# enter the full path of all Joomla root directories on your server, space separated
pathlist="/home/username1/public_html/ /home/username2/public_html/"
for p in ${pathlist}
do
cd $p
unzip -o -qq $patch
echo $p $patch unzipped
done
echo All Joomla sites in pathlist updated
This script works perfectly assuming:
- You are in charge of updating all sites - not your clients.
- No hacks to the Joomla core were done - updating may break your site.
- You do have ssh access to your server environment.