blob: c904a70ed0a6a8a19d734e087d8e29f04cc0e07e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/bin/bash
#
# Mediawiki upgrader.
#
# Config parameters
BASENAME="`basename $0`"
RELEASES="http://releases.wikimedia.org/mediawiki/"
# Sudo config
if [ "`whoami`" != 'root' ]; then
sudo="sudo"
fi
# Deploy
function mediawiki_deploy {
VERSION="$1"
MAJOR_VERSION="`echo $VERSION | cut -d . --fields=1,2`"
TARBALL="mediawiki-$VERSION.tar.gz"
# Version check
if [ -z "$VERSION" ]; then
echo "usage: $BASENAME deploy <version>"
exit 1
elif [ -d "mediawiki-$VERSION" ]; then
echo "mediawiki-$VERSION already installed."
exit
fi
$sudo wget $RELEASES/$MAJOR_VERSION/$TARBALL || exit 1
$sudo wget $RELEASES/$MAJOR_VERSION/$TARBALL.sig || exit 1
gpg --verify $TARBALL.sig $TARBALL
$sudo tar xvf $TARBALL || exit 1
$sudo chown -R root. mediawiki-$VERSION || exit 1
$sudo rm $TARBALL*
$sudo ln -sf mediawiki-$VERSION mediawiki
}
# Upgrade
function mediawiki_upgrade {
OLD_VERSION="$1"
VERSION="$2"
# Version check
if [ -z "$VERSION" ]; then
echo "usage: $BASENAME upgrade <old-version> <new-version>"
exit 1
elif [ -d "mediawiki-$VERSION" ]; then
echo "mediawiki-$VERSION already installed."
exit
elif [ ! -d "mediawiki-$OLD_VERSION" ]; then
echo "error: mediawiki-$OLD_VERSION is not installed, aborting."
exit 1
fi
# Deploy
mediawiki_deploy $VERSION
# Copy configuration
$sudo cp -a mediawiki-$OLD_VERSION/LocalSettings*.php mediawiki-$VERSION/
# Contrib extensions
if [ -d "mediawiki-$OLD_VERSION/contrib" ]; then
$sudo cp -a mediawiki-$OLD_VERSION/contrib mediawiki-$VERSION/
# Symlink extensions
for extension in `ls mediawiki-$OLD_VERSION/extensions`; do
if [ -h "mediawiki-$OLD_VERSION/extensions/$extension" ]; then
$sudo cp -ar mediawiki-$OLD_VERSION/extensions/$extension mediawiki-$VERSION/extensions/
fi
done
fi
# Audit
echo "Audit:"
du -hs mediawiki-$OLD_VERSION
du -hs mediawiki-$VERSION
}
# Main
if [ -z "$1" ]; then
echo "Usage: $BASENAME <deploy|upgrade> [arguments]"
exit 1
elif [ "$1" == "deploy" ]; then
shift
mediawiki_deploy $*
elif [ "$1" == "upgrade" ]; then
shift
mediawiki_upgrade $*
else
echo "No action $1"
exit 1
fi
|