Skip to content

Instantly share code, notes, and snippets.

@tiefpunkt
Last active August 29, 2015 14:07
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiefpunkt/1a96bc816df2f1c3924e to your computer and use it in GitHub Desktop.
Save tiefpunkt/1a96bc816df2f1c3924e to your computer and use it in GitHub Desktop.
Update a MediaWiki installation using patch files
#!/bin/bash
confirm () {
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
if [ "$USER" != "root" ]; then
echo Needs to be run as root.
exit 1
fi
if [ ! -f LocalSettings.php ]; then
echo No LocalSettings.php file found.
echo Please cd to MediaWiki root directory
exit 1
fi
echo -- Backing up installation.
tar cfz ../../mw_upgrade_$(date +%F_%T).tgz .
echo -- Backup finished.
echo -- Strating dry run of patch.
patch -p 1 --dry-run < $1
echo -- Dry run finished.
echo Do you want to continue with applying the patch?
confirm || exit 1
echo -- Start applying the patch.
patch -p 1 < $1
echo -- Patch applied.
echo Will update database now.
confirm || exit 1
echo -- Updating Database.
php maintenance/update.php --quick -quiet
echo -- Database update finished.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment