Skip to content

Instantly share code, notes, and snippets.

@TimKraemer
Created June 29, 2016 11:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimKraemer/a44d02318867fde500364624ca44dea2 to your computer and use it in GitHub Desktop.
Save TimKraemer/a44d02318867fde500364624ca44dea2 to your computer and use it in GitHub Desktop.
#!/bin/bash
# automagically downloads the newest stable mediawiki and it's php dependencies
MW_PATH="/export/home/wwwfsr/fachschaft/wiki" # set your mediawiki path here
MW_stable_branch_number=$(curl -s "https://www.mediawiki.org/w/api.php?action=expandtemplates&text=\{\{MW%20stable%20branch%20number\}\}&prop=wikitext&formatversion=2&format=json" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["expandtemplates"]["wikitext"]')
MW_stable_release_number=$(curl -s "https://www.mediawiki.org/w/api.php?action=expandtemplates&text=\{\{MW%20stable%20release%20number\}\}&prop=wikitext&formatversion=2&format=json" | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["expandtemplates"]["wikitext"]')
wget "http://releases.wikimedia.org/mediawiki/$MW_stable_branch_number/mediawiki-$MW_stable_release_number.tar.gz" -P /tmp/
tar -xzf "/tmp/mediawiki-$MW_stable_release_number.tar.gz" -C $MW_PATH --strip-components=1
rm "/tmp/mediawiki-$MW_stable_release_number.tar.gz"
# first, self-update composer
echo "updating composer and dependencies"
cd $MW_PATH
php composer.phar self-update
# run the composer update yourself (shouldn't be neccessary, since mediawikis update does this, I think)
#php composer.phar update
# then, update mediawiki database
php $MW_PATH/maintenance/update.php
# on this server, we had to comment out the FollowSymLinks directive for some reason
# (if we kept this directive, the webserver wasn't allowed to access the images)
# shouldn't be neccessary for the most configurations
# sed -i -e 's/Options +FollowSymLinks/\#Options +FollowSymLinks/g' $MW_PATH/images/.htaccess
echo "\033[0;32m MediaWiki update to $MW_stable_release_number complete! \033[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment