DevelopmentServer: mediawiki-upgrade

File mediawiki-upgrade, 2.4 KB (added by chris, 6 years ago)
Line 
1#!/bin/bash
2
3MW_DIR=/web/wiki.dev.transitionnetwork.org
4MW_DOC_ROOT=$MW_DIR/www
5MW_REPO=http://svn.wikimedia.org/svnroot/mediawiki/branches
6MW_EXTENSIONS=$MW_DOC_ROOT/extensions
7
8# Make sure only root can run our script
9if [ "$(id -u)" != "0" ]; then
10   echo "This script must be run as root" 1>&2
11   exit 1
12fi
13if [[ $HOME != "/root" ]]; then
14   echo "This script must be run as root user not via sudo"  1>&2
15   exit 1
16fi
17
18# get the version to upgrade to
19if [[ $1 ]]; then
20  MW_VERSION=$1
21else
22  printf "Specify the latest version of Mediawiki in the format 1.16.0:"
23  read MW_VERSION
24fi
25
26# backup the mysql databases
27echo "Backuping to the databases to /var/backup/mysql"
28/usr/local/bin/mysql_backup
29echo "Databases backuped to /var/backup/mysql"
30
31# work out which directory the files will be in on http://download.wikimedia.org/mediawiki/
32MW_VERSION_DIR=`echo ${MW_VERSION%.*}`
33
34# download and extract
35cd $MW_DIR
36wget http://download.wikimedia.org/mediawiki/$MW_VERSION_DIR/mediawiki-$MW_VERSION.tar.gz || echo "There was a problem downloading mediawiki-$MW_VERSION.tar.gz"
37wget http://download.wikimedia.org/mediawiki/$MW_VERSION_DIR/mediawiki-$MW_VERSION.tar.gz.sig \
38  || echo "There was a problem downloading ediawiki-$MW_VERSION.tar.gz.sig"
39gpg --verify mediawiki-$MW_VERSION.tar.gz.sig \
40  || echo "There was a problem with the gpg sig"
41tar -zxf mediawiki-$MW_VERSION.tar.gz \
42  || echo "There was a problem extracting mediawiki-$MW_VERSION.tar.gz"
43
44# copy the new files over the installed version
45chown root:root -R mediawiki-$MW_VERSION/
46rsync -a mediawiki-$MW_VERSION/ $MW_DOC_ROOT/ \
47  || echo "There was a problem copying the files"
48chown www-data:www-data -R $MW_DOC_ROOT/images
49
50# run the update.php
51cd $MW_DOC_ROOT/maintenance/
52php update.php \
53  || echo "There was a problem running $MW_DOC_ROOT/maintenance/update.php"
54
55echo "Mediawiki upgraded to $MW_VERSION"
56
57# update modules
58
59# we need the version in the format REL1_16 see
60# http://svn.wikimedia.org/svnroot/mediawiki/tags/extensions
61MW_REPO_VERSION=REL`echo $MW_VERSION_DIR | sed -e 's/\./_/'`
62
63cd $MW_EXTENSIONS
64
65# get the extensions from the mediawiki repo
66for e in SyntaxHighlight_GeSHi SpamBlacklist FCKeditor
67do
68  echo "Updating $e"
69  cd $e
70  svn switch $MW_REPO/$MW_REPO_VERSION/extensions/$e || echo "There was a problem switching $e"
71  cd $MW_EXTENSIONS
72done
73
74echo "Mediawiki extensions, $e upgraded to versions from $MW_REPO/$MW_REPO_VERSION/extensions/"
75