diff options
Diffstat (limited to 'mediawiki-dl')
-rwxr-xr-x | mediawiki-dl | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/mediawiki-dl b/mediawiki-dl new file mode 100755 index 0000000..d6e873c --- /dev/null +++ b/mediawiki-dl @@ -0,0 +1,84 @@ +#!/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" + + if [ -z "$VERSION" ]; then + echo "usage: $BASENAME deploy <version>" + exit 1 + fi + + wget $RELEASES/$MAJOR_VERSION/$TARBALL + wget $RELEASES/$MAJOR_VERSION/$TARBALL.sig + gpg --verify $TARBALL.sig $TARBALL + tar xvf $TARBALL + $sudo chown -R root. mediawiki-$VERSION + rm $TARBALL* + ln -sf mediawiki-$VERSION mediawiki +} + +# Upgrade +function mediawiki_upgrade { + OLD_VERSION="$1" + VERSION="$2" + + if [ -z "$VERSION" ]; then + echo "usage: $BASENAME upgrade <old-version> <new-version>" + exit 1 + fi + + # Deploy + mediawiki_deploy $VERSION + + # Copy configuration + $sudo cp -a mediawiki-$OLD_VERSION/LocalSettings.php mediawiki-$VERSION/ + + # Symlink extensions + if [ -d "mediawiki-$OLD_VERSION/contrib" ]; then + $sudo cp -a mediawiki-$OLD_VERSION/contrib mediawiki-$VERSION/ + + for extension in mediawiki-$VERSION/contrib/*; do + if [ -d "mediawiki-$VERSION/contrib/$extension" ]; then + ( + cd mediawiki-$VERSION/extensions + $sudo ln -s ../contrib/$extension + ) + 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 |