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