Last active
August 29, 2015 14:07
-
-
Save tiefpunkt/1a96bc816df2f1c3924e to your computer and use it in GitHub Desktop.
Update a MediaWiki installation using patch files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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