Instantly share code, notes, and snippets.

Embed
What would you like to do?
Runs mediawiki update and rebuildall scripts for each wiki instance in a wikifarm
#!/usr/bin/perl
# Copyright (c) 2007 Shawn M. Douglas (shawndouglas.com)
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# This script generates a shell script to perform a wiki farm upgrade (to 1.9.3)
# It assumes the presence of "upgrade.list" which is a tab-delimited file
# containing two tab-delimited fields for each wiki:
# 1) directory/database suffix
# 2) pretty url (from $wgArticlePath)
# Specifically, the script
# -loops through list of wikis
# -removes old symlinks and creates new ones
# -creates a new LocalSettings.php file based on the template found in the "01" wiki directory
# -runs the upgrade.php script
# -runs the rebuildall.php script
$ts = `date "+%y%m%d"`;
chomp($ts);
print <<EOF;
#!/bin/sh -x
EOF
open(LIST, "<upgrade.list");
while (<LIST>) {
chomp;
split "\t";
print <<EOF;
cd /Library/WebServer/Documents/$_[0]
rm AdminSettings.php
rm COPYING
rm FAQ
rm HISTORY
rm INSTALL
rm README
rm RELEASE-NOTES
rm UPGRADE
rm docs
rm extensions
rm img_auth.php
rm includes
rm index.php
rm install-utils.inc
rm languages
rm maintenance
rm math
rm profileinfo.php
rm redirect.php
rm redirect.phtml
rm skins
rm tests
rm thumb.php
rm trackback.php
rm wiki.phtml
ln -s ../mediawiki2/AdminSettings.php
ln -s ../mediawiki2/Makefile
ln -s ../mediawiki2/StartProfiler.php
ln -s ../mediawiki2/api.php
ln -s ../mediawiki2/bin
ln -s ../mediawiki2/docs
ln -s ../mediawiki2/extensions
ln -s ../mediawiki2/img_auth.php
ln -s ../mediawiki2/includes
ln -s ../mediawiki2/index.php
ln -s ../mediawiki2/install-utils.inc
ln -s ../mediawiki2/languages
ln -s ../mediawiki2/locale
ln -s ../mediawiki2/maintenance
ln -s ../mediawiki2/math
ln -s ../mediawiki2/opensearch_desc.php
ln -s ../mediawiki2/profileinfo.php
ln -s ../mediawiki2/redirect.php
ln -s ../mediawiki2/redirect.phtml
ln -s ../mediawiki2/serialized
ln -s ../mediawiki2/skins
ln -s ../mediawiki2/t
ln -s ../mediawiki2/tests
ln -s ../mediawiki2/thumb.php
ln -s ../mediawiki2/trackback.php
ln -s ../mediawiki2/wiki.phtml
cp /Library/WebServer/Documents/01/6tna.png .
cp /Library/WebServer/Documents/$_[0]/LocalSettings.php /Library/WebServer/Documents/$_[0]/LocalSettings.php.$ts
cat /Library/WebServer/Documents/01/LocalSettings.php | sed s/smd/$_[1]/ | sed s/01/$_[0]/ | sed s/wikidb01/wikidb$_[0
]/ > /Library/WebServer/Documents/$_[0]/LocalSettings.php
/usr/local/php5/bin/php /Library/WebServer/Documents/mediawiki-1.9.3/maintenance/update.php --conf /Library/WebServer/
Documents/$_[0]/LocalSettings.php
/usr/local/php5/bin/php /Library/WebServer/Documents/mediawiki-1.9.3/maintenance/rebuildall.php --conf /Library/WebSer
ver/Documents/$_[0]/LocalSettings.php
EOF
}
close(LIST);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment