Move addWiki, dumpInterwiki, ourusers, rebuildInterwiki, renameWiki and Site to Wikim...
authorSam Reed <reedy@users.mediawiki.org>
Wed, 7 Sep 2011 20:40:42 +0000 (20:40 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Wed, 7 Sep 2011 20:40:42 +0000 (20:40 +0000)
maintenance/Site.php [deleted file]
maintenance/addwiki.php [deleted file]
maintenance/dumpInterwiki.php [deleted file]
maintenance/ourusers.php [deleted file]
maintenance/rebuildInterwiki.php [deleted file]
maintenance/renamewiki.php [deleted file]

diff --git a/maintenance/Site.php b/maintenance/Site.php
deleted file mode 100644 (file)
index 87d637b..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-/**
- * @todo document
- * @ingroup Maintenance
- */
-class Site {
-       var $suffix, $lateral, $url;
-
-       function __construct( $s, $l, $u ) {
-               $this->suffix = $s;
-               $this->lateral = $l;
-               $this->url = $u;
-       }
-
-       function getURL( $lang, $urlprotocol ) {
-               $xlang = str_replace( '_', '-', $lang );
-               return "$urlprotocol//$xlang.{$this->url}/wiki/\$1";
-       }
-}
diff --git a/maintenance/addwiki.php b/maintenance/addwiki.php
deleted file mode 100644 (file)
index d75cce5..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-<?php
-/**
- * @defgroup Wikimedia Wikimedia
- */
-
-/**
- * Add a new wiki
- * Wikimedia specific!
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- * @ingroup Wikimedia
- */
-
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
-
-class AddWiki extends Maintenance {
-       public function __construct() {
-               global $wgNoDBParam;
-
-               parent::__construct();
-               $this->mDescription = "Add a new wiki to the family. Wikimedia specific!";
-               $this->addArg( 'language', 'Language code of new site, e.g. en' );
-               $this->addArg( 'site', 'Type of site, e.g. wikipedia' );
-               $this->addArg( 'dbname', 'Name of database to create, e.g. enwiki' );
-               $this->addArg( 'domain', 'Domain name of the wiki, e.g. en.wikipedia.org' );
-
-               $wgNoDBParam = true;
-       }
-
-       public function getDbType() {
-               return Maintenance::DB_ADMIN;
-       }
-
-       public function execute() {
-               global $IP, $wgDefaultExternalStore, $wmfVersionNumber;
-               if ( !$wmfVersionNumber ) { // set in CommonSettings.php
-                       $this->error( '$wmfVersionNumber is not set, please use MWScript.php wrapper.', true );
-               }
-
-               $lang = $this->getArg( 0 );
-               $site = $this->getArg( 1 );
-               $dbName = $this->getArg( 2 );
-               $domain = $this->getArg( 3 );
-               $languageNames = Language::getLanguageNames();
-
-               if ( !isset( $languageNames[$lang] ) ) {
-                       $this->error( "Language $lang not found in Names.php", true );
-               }
-               $name = $languageNames[$lang];
-
-               $dbw = wfGetDB( DB_MASTER );
-               $common = "/home/wikipedia/common";
-
-               $this->output( "Creating database $dbName for $lang.$site ($name)\n" );
-
-               # Set up the database
-               $dbw->query( "SET table_type=Innodb" );
-               $dbw->query( "CREATE DATABASE $dbName" );
-               $dbw->selectDB( $dbName );
-
-               $this->output( "Initialising tables\n" );
-               $dbw->sourceFile( $this->getDir() . '/tables.sql' );
-               $dbw->sourceFile( "$IP/extensions/OAI/update_table.sql" );
-               $dbw->sourceFile( "$IP/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql" );
-               $dbw->sourceFile( "$IP/extensions/CheckUser/cu_changes.sql" );
-               $dbw->sourceFile( "$IP/extensions/CheckUser/cu_log.sql" );
-               $dbw->sourceFile( "$IP/extensions/TitleKey/titlekey.sql" );
-               $dbw->sourceFile( "$IP/extensions/Oversight/hidden.sql" );
-               $dbw->sourceFile( "$IP/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql" );
-               $dbw->sourceFile( "$IP/extensions/AbuseFilter/abusefilter.tables.sql" );
-               $dbw->sourceFile( "$IP/extensions/PrefStats/patches/PrefStats.sql" );
-               $dbw->sourceFile( "$IP/extensions/ProofreadPage/ProofreadPage.sql" );
-               $dbw->sourceFile( "$IP/extensions/ClickTracking/patches/ClickTrackingEvents.sql" );
-               $dbw->sourceFile( "$IP/extensions/ClickTracking/patches/ClickTracking.sql" );
-               $dbw->sourceFile( "$IP/extensions/UserDailyContribs/patches/UserDailyContribs.sql" );
-
-               $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
-
-               # Initialise external storage
-               if ( is_array( $wgDefaultExternalStore ) ) {
-                       $stores = $wgDefaultExternalStore;
-               } elseif ( $wgDefaultExternalStore ) {
-                       $stores = array( $wgDefaultExternalStore );
-               } else {
-                       $stores = array();
-               }
-               if ( count( $stores ) ) {
-                       global $wgDBuser, $wgDBpassword, $wgExternalServers;
-                       foreach ( $stores as $storeURL ) {
-                               $m = array();
-                               if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
-                                       continue;
-                               }
-
-                               $cluster = $m[1];
-                               $this->output( "Initialising external storage $cluster...\n" );
-
-                               # Hack
-                               $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
-                               $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
-
-                               $store = new ExternalStoreDB;
-                               $extdb = $store->getMaster( $cluster );
-                               $extdb->query( "SET table_type=InnoDB" );
-                               $extdb->query( "CREATE DATABASE $dbName" );
-                               $extdb->selectDB( $dbName );
-
-                               # Hack x2
-                               $blobsTable = $store->getTable( $extdb );
-                               $sedCmd = "sed s/blobs\\\\\\>/$blobsTable/ " . $this->getDir() . "/storage/blobs.sql";
-                               $blobsFile = popen( $sedCmd, 'r' );
-                               $extdb->sourceStream( $blobsFile );
-                               pclose( $blobsFile );
-                               $extdb->commit();
-                       }
-               }
-
-               $title = Title::newFromText( wfMessage( 'mainpage' )->inLanguage( $lang )->useDatabase( false )->plain() );
-               $this->output( "Writing main page to " . $title->getPrefixedDBkey() . "\n" );
-               $article = new Article( $title );
-               $ucsite = ucfirst( $site );
-
-               $article->doEdit( $this->getFirstArticle( $ucsite, $name ), '', EDIT_NEW | EDIT_AUTOSUMMARY );
-
-               $this->output( "Adding to dblists\n" );
-
-               # Add to dblist
-               $file = fopen( "$common/all.dblist", "a" );
-               fwrite( $file, "$dbName\n" );
-               fclose( $file );
-
-               # Update the sublists
-               shell_exec( "cd $common && ./refresh-dblist" );
-
-               # Add to wikiversions.dat
-               $file = fopen( "$common/wikiversions.dat", "a" );
-               fwrite( $file, "$dbName php-$wmfVersionNumber\n" );
-               fclose( $file );
-               # Rebuild wikiversions.cdb
-               shell_exec( "cd $common/multiversion && ./refreshWikiversionsCDB" );
-
-               # print "Constructing interwiki SQL\n";
-               # Rebuild interwiki tables
-               # passthru( '/home/wikipedia/conf/interwiki/update' );
-
-               $time = wfTimestamp( TS_RFC2822 );
-               // These arguments need to be escaped twice: once for echo and once for at
-               $escDbName = wfEscapeShellArg( wfEscapeShellArg( $dbName ) );
-               $escTime = wfEscapeShellArg( wfEscapeShellArg( $time ) );
-               $escUcsite = wfEscapeShellArg( wfEscapeShellArg( $ucsite ) );
-               $escName = wfEscapeShellArg( wfEscapeShellArg( $name ) );
-               $escLang = wfEscapeShellArg( wfEscapeShellArg( $lang ) );
-               $escDomain = wfEscapeShellArg( wfEscapeShellArg( $domain ) );
-               shell_exec( "echo notifyNewProjects $escDbName $escTime $escUcsite $escName $escLang $escDomain | at now + 15 minutes" );
-
-               $this->output( "Script ended. You still have to:
-       * Add any required settings in InitialiseSettings.php
-       * Run sync-common-all
-       * Run /home/wikipedia/conf/interwiki/update
-       " );
-       }
-
-       private function getFirstArticle( $ucsite, $name ) {
-               return <<<EOT
-==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
-
-* Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|Beta Wikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here.
-
-* If you would like to help translating the interface to this language, please do not translate here, but go to [[translatewiki:|translatewiki.net]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].
-
-* For information about how to edit and for other general help, see [[m:Help:Contents|Help on Wikimedia's Meta-Wiki]] or [[mw:Help:Contents|Help on MediaWiki.org]].
-
-== Sister projects ==
-<span class="plainlinks">
-[http://www.wikipedia.org Wikipedia] |
-[http://www.wiktionary.org Wiktionary] |
-[http://www.wikibooks.org Wikibooks] |
-[http://www.wikinews.org Wikinews] |
-[http://www.wikiquote.org Wikiquote] |
-[http://www.wikisource.org Wikisource] |
-[http://www.wikiversity.org Wikiversity]
-</span>
-
-See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
-
-EOT;
-       }
-}
-
-$maintClass = "AddWiki";
-require_once( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/dumpInterwiki.php b/maintenance/dumpInterwiki.php
deleted file mode 100644 (file)
index e1170bd..0000000
+++ /dev/null
@@ -1,265 +0,0 @@
-<?php
-/**
- * Build constant slightly compact database of interwiki prefixes
- * Wikimedia specific!
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @todo document
- * @ingroup Maintenance
- * @ingroup Wikimedia
- */
-
-require_once( dirname( __FILE__ ) . '/Site.php' );
-
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
-
-class DumpInterwiki extends Maintenance {
-
-       public function __construct() {
-               parent::__construct();
-               $this->mDescription = "Build constant slightly compact database of interwiki prefixes.";
-               $this->addOption( 'langlist', 'File with one language code per line', false, true );
-               $this->addOption( 'dblist', 'File with one db per line', false, true );
-               $this->addOption( 'specialdbs', "File with one 'special' db per line", false, true );
-               $this->addOption( 'o', 'Cdb output file', false, true );
-               $this->addOption( 'protocolrelative', 'Output wikimedia interwiki urls as protocol relative', false, false );
-       }
-
-       function execute() {
-               # List of language prefixes likely to be found in multi-language sites
-               $this->langlist = array_map( "trim", file( $this->getOption( 'langlist', "/home/wikipedia/common/langlist" ) ) );
-
-               # List of all database names
-               $this->dblist = array_map( "trim", file( $this->getOption( 'dblist', "/home/wikipedia/common/all.dblist" ) ) );
-
-               # Special-case databases
-               $this->specials = array_flip(   array_map( "trim", file( $this->getOption( 'specialdbs', "/home/wikipedia/common/special.dblist" ) ) ) );
-
-               if ( $this->hasOption( 'o' ) ) {
-                       $this->dbFile = CdbWriter::open( $this->getOption( 'o' ) ) ;
-               } else {
-                       $this->dbFile = false;
-               }
-
-               if ( $this->hasOption( 'protocolrelative' ) ) {
-                       $this->urlprotocol = '';
-               } else {
-                       $this->urlprotocol = 'http:';
-               }
-
-               $this->getRebuildInterwikiDump();
-       }
-
-       function getRebuildInterwikiDump() {
-               global $wgContLang;
-
-               # Multi-language sites
-               # db suffix => db suffix, iw prefix, hostname
-               $sites = array(
-                       'wiki' => new Site( 'wiki', 'w', 'wikipedia.org' ),
-                       'wiktionary' => new Site( 'wiktionary', 'wikt', 'wiktionary.org' ),
-                       'wikiquote' => new Site( 'wikiquote', 'q', 'wikiquote.org' ),
-                       'wikibooks' => new Site( 'wikibooks', 'b', 'wikibooks.org' ),
-                       'wikinews' => new Site( 'wikinews', 'n', 'wikinews.org' ),
-                       'wikisource' => new Site( 'wikisource', 's', 'wikisource.org' ),
-                       'wikimedia' => new Site( 'wikimedia', 'chapter', 'wikimedia.org' ),
-                       'wikiversity' => new Site( 'wikiversity', 'v', 'wikiversity.org' ),
-               );
-
-               # Extra interwiki links that can't be in the intermap for some reason
-               $extraLinks = array(
-                       array( 'm', $this->urlprotocol . '//meta.wikimedia.org/wiki/$1', 1 ),
-                       array( 'meta', $this->urlprotocol . '//meta.wikimedia.org/wiki/$1', 1 ),
-                       array( 'sep11', $this->urlprotocol . '//sep11.wikipedia.org/wiki/$1', 1 ),
-               );
-
-               # Language aliases, usually configured as redirects to the real wiki in apache
-               # Interlanguage links are made directly to the real wiki
-               # Something horrible happens if you forget to list an alias here, I can't
-               #   remember what
-               $this->languageAliases = array(
-                       'zh-cn' => 'zh',
-                       'zh-tw' => 'zh',
-                       'dk' => 'da',
-                       'nb' => 'no',
-               );
-
-               # Special case prefix rewrites, for the benefit of Swedish which uses s:t
-               # as an abbreviation for saint
-               $this->prefixRewrites = array(
-                       'svwiki' => array( 's' => 'src' ),
-               );
-
-               # Construct a list of reserved prefixes
-               $reserved = array();
-               foreach ( $this->langlist as $lang ) {
-                       $reserved[$lang] = 1;
-               }
-               foreach ( $this->languageAliases as $alias => $lang ) {
-                       $reserved[$alias] = 1;
-               }
-               foreach ( $sites as $site ) {
-                       $reserved[$site->lateral] = 1;
-               }
-
-               # Extract the intermap from meta
-               $intermap = Http::get( 'http://meta.wikimedia.org/w/index.php?title=Interwiki_map&action=raw', 30 );
-               $lines = array_map( 'trim', explode( "\n", trim( $intermap ) ) );
-
-               if ( !$lines || count( $lines ) < 2 ) {
-                       $this->error( "m:Interwiki_map not found", true );
-               }
-
-               # Global interwiki map
-               foreach ( $lines as $line ) {
-                       if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(.*?)\s*$/', $line, $matches ) ) {
-                               $prefix = $wgContLang->lc( $matches[1] );
-                               $prefix = str_replace( ' ', '_', $prefix );
-
-                               $url = $matches[2];
-                               if ( preg_match( '/(wikipedia|wiktionary|wikisource|wikiquote|wikibooks|wikimedia)\.org/', $url ) ) {
-                                       if ( $this->hasOption( 'protocolrelative' ) ) {
-                                               if ( substr( $url, 0, 5 ) == 'http:' ) {
-                                                       $url = substr( $url, 5 );
-                                               } else if ( substr( $url, 0, 6 ) == 'https:' ) {
-                                                       $url = substr( $url, 6 );
-                                               }
-                                       }
-                                       $local = 1;
-                               } else {
-                                       $local = 0;
-                               }
-
-                               if ( empty( $reserved[$prefix] ) ) {
-                                       $imap  = array( "iw_prefix" => $prefix, "iw_url" => $url, "iw_local" => $local );
-                                       $this->makeLink ( $imap, "__global" );
-                               }
-                       }
-               }
-
-               # Exclude Wikipedia for Wikipedia
-               $this->makeLink ( array ( 'iw_prefix' => 'wikipedia', 'is_url' => null ), "_wiki" );
-
-               # Multilanguage sites
-               foreach ( $sites as $site ) {
-                       $this->makeLanguageLinks ( $site, "_" . $site->suffix );
-               }
-
-               foreach ( $this->dblist as $db ) {
-                       if ( isset( $this->specials[$db] ) ) {
-                               # Special wiki
-                               # Has interwiki links and interlanguage links to wikipedia
-
-                               $this->makeLink( array( 'iw_prefix' => $db, 'iw_url' => "wiki" ), "__sites" );
-                               # Links to multilanguage sites
-                               foreach ( $sites as $targetSite ) {
-                                       $this->makeLink( array( 'iw_prefix' => $targetSite->lateral,
-                                               'iw_url' => $targetSite->getURL( 'en', $this->urlprotocol ),
-                                               'iw_local' => 1 ), $db );
-                               }
-                       } else {
-                               # Find out which site this DB belongs to
-                               $site = false;
-                               foreach ( $sites as $candidateSite ) {
-                                       $suffix = $candidateSite->suffix;
-                                       if ( preg_match( "/(.*)$suffix$/", $db, $matches ) ) {
-                                               $site = $candidateSite;
-                                               break;
-                                       }
-                               }
-                               $this->makeLink( array( 'iw_prefix' => $db, 'iw_url' => $site->suffix ), "__sites" );
-                               if ( !$site ) {
-                                       $this->error( "Invalid database $db\n" );
-                                       continue;
-                               }
-                               $lang = $matches[1];
-
-                               # Lateral links
-                               foreach ( $sites as $targetSite ) {
-                                       if ( $targetSite->suffix != $site->suffix ) {
-                                               $this->makeLink( array( 'iw_prefix' => $targetSite->lateral,
-                                                       'iw_url' => $targetSite->getURL( $lang, $this->urlprotocol ),
-                                                       'iw_local' => 1 ), $db );
-                                       }
-                               }
-
-                               if ( $site->suffix == "wiki" ) {
-                                       $this->makeLink( array( 'iw_prefix' => 'w',
-                                               'iw_url' => $this->urlprotocol . "//en.wikipedia.org/wiki/$1",
-                                               'iw_local' => 1 ), $db );
-                               }
-
-                       }
-               }
-               foreach ( $extraLinks as $link ) {
-                       $this->makeLink( $link, "__global" );
-               }
-
-               # List prefixes for each source
-               foreach ( $this->prefixLists as $source => $hash ) {
-                       $list = array_keys( $hash );
-                       sort( $list );
-                       if ( $this->dbFile ) {
-                               $this->dbFile->set( "__list:{$source}", implode( ' ', $list ) );
-                       } else {
-                               print "__list:{$source} " . implode( ' ', $list ) . "\n";
-                       }
-               }
-       }
-
-       # ------------------------------------------------------------------------------------------
-
-       # Executes part of an INSERT statement, corresponding to all interlanguage links to a particular site
-       function makeLanguageLinks( &$site, $source ) {
-               # Actual languages with their own databases
-               foreach ( $this->langlist as $targetLang ) {
-                       $this->makeLink( array( $targetLang, $site->getURL( $targetLang, $this->urlprotocol ), 1 ), $source );
-               }
-
-               # Language aliases
-               foreach ( $this->languageAliases as $alias => $lang ) {
-                       $this->makeLink( array( $alias, $site->getURL( $lang, $this->urlprotocol ), 1 ), $source );
-               }
-       }
-
-       function makeLink( $entry, $source ) {
-               if ( isset( $this->prefixRewrites[$source] ) && isset( $this->prefixRewrites[$source][$entry[0]] ) )
-                       $entry[0] = $this->prefixRewrites[$source][$entry[0]];
-
-               if ( !array_key_exists( "iw_prefix", $entry ) ) {
-                       $entry = array( "iw_prefix" => $entry[0], "iw_url" => $entry[1], "iw_local" => $entry[2] );
-               }
-               if ( array_key_exists( $source, $this->prefixRewrites ) &&
-                               array_key_exists( $entry['iw_prefix'], $this->prefixRewrites[$source] ) ) {
-                       $entry['iw_prefix'] = $this->prefixRewrites[$source][$entry['iw_prefix']];
-               }
-
-               if ( $this->dbFile ) {
-                       $this->dbFile->set( "{$source}:{$entry['iw_prefix']}", trim( "{$entry['iw_local']} {$entry['iw_url']}" ) );
-               } else {
-                       $this->output( "{$source}:{$entry['iw_prefix']} {$entry['iw_url']} {$entry['iw_local']}\n" );
-               }
-
-               # Add to list of prefixes
-               $this->prefixLists[$source][$entry['iw_prefix']] = 1;
-       }
-}
-
-$maintClass = "DumpInterwiki";
-require_once( RUN_MAINTENANCE_IF_MAIN );
-
diff --git a/maintenance/ourusers.php b/maintenance/ourusers.php
deleted file mode 100644 (file)
index c8578e2..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<?php
-/**
- * Wikimedia specific
- *
- * This script generates SQL used to update MySQL users on a hardcoded
- * list of hosts. It takes care of setting the wikiuser for every
- * database as well as setting up wikiadmin.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @todo document
- * @file
- * @ingroup Maintenance
- * @ingroup Wikimedia
- */
-
-/** */
-$wikiuser_pass = `wikiuser_pass`;
-$wikiadmin_pass = `wikiadmin_pass`;
-$nagios_pass = `nagios_sql_pass`;
-
-$hosts = array(
-       'localhost',
-       '10.0.%',
-       '66.230.200.%',
-       '208.80.152.%',
-);
-
-$databases = array(
-       '%wik%',
-       'centralauth',
-);
-
-print "/*!40100 set old_passwords=1 */;\n";
-print "/*!40100 set global old_passwords=1 */;\n";
-
-foreach ( $hosts as $host ) {
-       print "--\n-- $host\n--\n";
-       print "\n-- wikiuser\n\n";
-       print "GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
-       print "GRANT ALL PRIVILEGES ON `boardvote%`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
-       foreach ( $databases as $db ) {
-               print "GRANT SELECT, INSERT, UPDATE, DELETE ON `$db`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
-       }
-
-       print "\n-- wikiadmin\n\n";
-       print "GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'wikiadmin'@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
-       print "GRANT ALL PRIVILEGES ON `boardvote%`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
-       foreach ( $databases as $db ) {
-               print "GRANT ALL PRIVILEGES ON `$db`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
-       }
-       print "\n-- nagios\n\n";
-       print "GRANT REPLICATION CLIENT ON *.* TO 'nagios'@'$host' IDENTIFIED BY '$nagios_pass';\n";
-
-       print "\n";
-}
-
diff --git a/maintenance/rebuildInterwiki.php b/maintenance/rebuildInterwiki.php
deleted file mode 100644 (file)
index 25aea2d..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-<?php
-/**
- * Rebuild interwiki table using the file on meta and the language list
- * Wikimedia specific!
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @todo document
- * @ingroup Maintenance
- * @ingroup Wikimedia
- */
-
-require_once( dirname( __FILE__ ) . '/Site.php' );
-
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
-
-class RebuildInterwiki extends Maintenance {
-       public function __construct() {
-               parent::__construct();
-               $this->mDescription = "Rebuild the interwiki table using the file on meta and the language list.";
-               $this->addOption( 'langlist', 'File with one language code per line', false, true );
-               $this->addOption( 'dblist', 'File with one db per line', false, true );
-               $this->addOption( 'd', 'Output folder', false, true );
-       }
-
-       function execute() {
-               # List of language prefixes likely to be found in multi-language sites
-               $this->langlist = array_map( "trim", file( $this->getOption( 'langlist', "/home/wikipedia/common/langlist" ) ) );
-
-               # List of all database names
-               $this->dblist = array_map( "trim", file( $this->getOption( 'dblist', "/home/wikipedia/common/all.dblist" ) ) );
-
-               # Special-case databases
-               //$this->specials = array_flip( array_map( "trim", file( $this->getOption( 'specialdbs', "/home/wikipedia/common/special.dblist" ) ) ) );
-
-               $this->makeInterwikiSQL( $this->getOption( 'd', '/home/wikipedia/conf/interwiki/sql' ) );
-       }
-
-       function makeInterwikiSQL( $destDir ) {
-               $this->output( "Making new interwiki SQL files in $destDir\n" );
-
-               # Multi-language sites
-               # db suffix => db suffix, iw prefix, hostname
-               $sites = array(
-                       'wiki' => new Site( 'wiki', 'w', 'wikipedia.org' ),
-                       'wiktionary' => new Site( 'wiktionary', 'wikt', 'wiktionary.org' ),
-                       'wikiquote' => new Site( 'wikiquote', 'q', 'wikiquote.org' ),
-                       'wikibooks' => new Site( 'wikibooks', 'b', 'wikibooks.org' ),
-                       'wikinews' => new Site( 'wikinews', 'n', 'wikinews.org' ),
-                       'wikisource' => new Site( 'wikisource', 's', 'wikisource.org' ),
-                       'wikimedia' => new Site( 'wikimedia', 'chapter', 'wikimedia.org' ),
-                       'wikiversity' => new Site( 'wikiversity', 'v', 'wikiversity.org' ),
-               );
-
-               # Special-case hostnames
-               $this->specials = array(
-                       'sourceswiki' => 'sources.wikipedia.org',
-                       'quotewiki' => 'wikiquote.org',
-                       'textbookwiki' => 'wikibooks.org',
-                       'sep11wiki' => 'sep11.wikipedia.org',
-                       'metawiki' => 'meta.wikimedia.org',
-                       'commonswiki' => 'commons.wikimedia.org',
-                       'specieswiki' => 'species.wikimedia.org',
-               );
-
-               # Extra interwiki links that can't be in the intermap for some reason
-               $extraLinks = array(
-                       array( 'm', 'http://meta.wikimedia.org/wiki/$1', 1 ),
-                       array( 'meta', 'http://meta.wikimedia.org/wiki/$1', 1 ),
-                       array( 'sep11', 'http://sep11.wikipedia.org/wiki/$1', 1 ),
-               );
-
-               # Language aliases, usually configured as redirects to the real wiki in apache
-               # Interlanguage links are made directly to the real wiki
-               # Something horrible happens if you forget to list an alias here, I can't
-               #   remember what
-               $this->languageAliases = array(
-                       'zh-cn' => 'zh',
-                       'zh-tw' => 'zh',
-                       'dk' => 'da',
-                       'nb' => 'no',
-               );
-
-               # Special case prefix rewrites, for the benefit of Swedish which uses s:t
-               # as an abbreviation for saint
-               $this->prefixRewrites = array(
-                       'svwiki' => array( 's' => 'src' ),
-               );
-
-               # Construct a list of reserved prefixes
-               $reserved = array();
-               foreach ( $this->langlist as $lang ) {
-                       $reserved[$lang] = 1;
-               }
-               foreach ( $this->languageAliases as $alias => $lang ) {
-                       $reserved[$alias] = 1;
-               }
-               foreach ( $sites as $site ) {
-                       $reserved[$site->lateral] = 1;
-               }
-
-               # Extract the intermap from meta
-               $intermap = Http::get( 'http://meta.wikimedia.org/w/index.php?title=Interwiki_map&action=raw', 30 );
-               $lines = array_map( 'trim', explode( "\n", trim( $intermap ) ) );
-
-               if ( !$lines || count( $lines ) < 2 ) {
-                       $this->error( "m:Interwiki_map not found", true );
-               }
-
-               $iwArray = array();
-
-               foreach ( $lines as $line ) {
-                       $matches = array();
-                       if ( preg_match( '/^\|\s*(.*?)\s*\|\|\s*(https?:\/\/.*?)\s*$/', $line, $matches ) ) {
-                               $prefix = strtolower( $matches[1] );
-                               $url = $matches[2];
-                               if ( preg_match( '/(wikipedia|wiktionary|wikisource|wikiquote|wikibooks|wikimedia)\.org/', $url ) ) {
-                                       $local = 1;
-                               } else {
-                                       $local = 0;
-                               }
-
-                               if ( empty( $reserved[$prefix] ) ) {
-                                       $iwArray[$prefix] = array( "iw_prefix" => $prefix, "iw_url" => $url, "iw_local" => $local );
-                               }
-                       }
-               }
-
-               foreach ( $this->dblist as $db ) {
-                       $sql = "-- Generated by rebuildInterwiki.php";
-                       if ( isset( $this->specials[$db] ) ) {
-                               # Special wiki
-                               # Has interwiki links and interlanguage links to wikipedia
-
-                               $host = $this->specials[$db];
-                               $sql .= "\n--$host\n\n";
-                               $sql .= "USE $db;\n" .
-                                               "TRUNCATE TABLE interwiki;\n" .
-                                               "INSERT INTO interwiki (iw_prefix, iw_url, iw_local) VALUES \n";
-                               $first = true;
-
-                               # Intermap links
-                               foreach ( $iwArray as $iwEntry ) {
-                                       $sql .= $this->makeLink( $iwEntry, $first, $db );
-                               }
-
-                               # Links to multilanguage sites
-                               foreach ( $sites as $targetSite ) {
-                                       $sql .= $this->makeLink( array( $targetSite->lateral, $targetSite->getURL( 'en' ), 1 ), $first, $db );
-                               }
-
-                               # Interlanguage links to wikipedia
-                               $sql .= $this->makeLanguageLinks( $sites['wiki'], $first, $db );
-
-                               # Extra links
-                               foreach ( $extraLinks as $link ) {
-                                       $sql .= $this->makeLink( $link, $first, $db );
-                               }
-
-                               $sql .= ";\n";
-                       } else {
-                               # Find out which site this DB belongs to
-                               $site = false;
-                               foreach ( $sites as $candidateSite ) {
-                                       $suffix = $candidateSite->suffix;
-                                       if ( preg_match( "/(.*)$suffix$/", $db, $matches ) ) {
-                                               $site = $candidateSite;
-                                               break;
-                                       }
-                               }
-                               if ( !$site ) {
-                                       print "Invalid database $db\n";
-                                       continue;
-                               }
-                               $lang = $matches[1];
-                               $host = "$lang." . $site->url;
-                               $sql .= "\n--$host\n\n";
-
-                               $sql .= "USE $db;\n" .
-                                               "TRUNCATE TABLE interwiki;\n" .
-                                               "INSERT INTO interwiki (iw_prefix,iw_url,iw_local) VALUES\n";
-                               $first = true;
-
-                               # Intermap links
-                               foreach ( $iwArray as $iwEntry ) {
-                                       # Suppress links with the same name as the site
-                                       if ( ( $suffix == 'wiki' && $iwEntry['iw_prefix'] != 'wikipedia' ) ||
-                                               ( $suffix != 'wiki' && $suffix != $iwEntry['iw_prefix'] ) )
-                                       {
-                                               $sql .= $this->makeLink( $iwEntry, $first, $db );
-                                       }
-                               }
-
-                               # Lateral links
-                               foreach ( $sites as $targetSite ) {
-                                       # Suppress link to self
-                                       if ( $targetSite->suffix != $site->suffix ) {
-                                               $sql .= $this->makeLink( array( $targetSite->lateral, $targetSite->getURL( $lang ), 1 ), $first, $db );
-                                       }
-                               }
-
-                               # Interlanguage links
-                               $sql .= $this->makeLanguageLinks( $site, $first, $db );
-
-                               # w link within wikipedias
-                               # Other sites already have it as a lateral link
-                               if ( $site->suffix == "wiki" ) {
-                                       $sql .= $this->makeLink( array( "w", "http://en.wikipedia.org/wiki/$1", 1 ), $first, $db );
-                               }
-
-                               # Extra links
-                               foreach ( $extraLinks as $link ) {
-                                               $sql .= $this->makeLink( $link, $first, $db );
-                               }
-                               $sql .= ";\n";
-                       }
-                       file_put_contents( "$destDir/$db.sql", $sql );
-               }
-       }
-
-       # ------------------------------------------------------------------------------------------
-
-       # Returns part of an INSERT statement, corresponding to all interlanguage links to a particular site
-       function makeLanguageLinks( &$site, &$first, $source ) {
-               $sql = "";
-
-               # Actual languages with their own databases
-               foreach ( $this->langlist as $targetLang ) {
-                       $sql .= $this->makeLink( array( $targetLang, $site->getURL( $targetLang ), 1 ), $first, $source );
-               }
-
-               # Language aliases
-               foreach ( $this->languageAliases as $alias => $lang ) {
-                       $sql .= $this->makeLink( array( $alias, $site->getURL( $lang ), 1 ), $first, $source );
-               }
-               return $sql;
-       }
-
-       # Make SQL for a single link from an array
-       function makeLink( $entry, &$first, $source ) {
-
-               if ( isset( $this->prefixRewrites[$source] ) && isset($entry[0]) && isset( $this->prefixRewrites[$source][$entry[0]] ) ) {
-                       $entry[0] = $this->prefixRewrites[$source][$entry[0]];
-               }
-
-               $sql = "";
-               # Add comma
-               if ( $first ) {
-                       $first = false;
-               } else {
-                       $sql .= ",\n";
-               }
-               $dbr = wfGetDB( DB_SLAVE );
-               $sql .= "(" . $dbr->makeList( $entry ) . ")";
-               return $sql;
-       }
-}
-
-$maintClass = "RebuildInterwiki";
-require_once( RUN_MAINTENANCE_IF_MAIN );
-
diff --git a/maintenance/renamewiki.php b/maintenance/renamewiki.php
deleted file mode 100644 (file)
index 4146525..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-<?php
-/**
- * Why yes, this *is* another special-purpose Wikimedia maintenance script!
- * Should be fixed up and generalized.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- * @ingroup Maintenance
- * @ingroup Wikimedia
- */
-
-require_once( dirname( __FILE__ ) . '/Maintenance.php' );
-
-class RenameWiki extends Maintenance {
-       public function __construct() {
-               parent::__construct();
-               $this->mDescription = "Rename external storage dbs and leave a new one";
-               $this->addArg( 'olddb', 'Old DB name' );
-               $this->addArg( 'newdb', 'New DB name' );
-       }
-
-       public function getDbType() {
-               return Maintenance::DB_ADMIN;
-       }
-
-       public function execute() {
-               global $wgDefaultExternalStore;
-
-               # Setup
-               $from = $this->getArg( 0 );
-               $to = $this->getArg( 1 );
-               $this->output( "Renaming blob tables in ES from $from to $to...\n" );
-               $this->output( "Sleeping 5 seconds...\n" );
-               sleep( 5 );
-
-               # Initialise external storage
-               if ( is_array( $wgDefaultExternalStore ) ) {
-                       $stores = $wgDefaultExternalStore;
-               } elseif ( $wgDefaultExternalStore ) {
-                       $stores = array( $wgDefaultExternalStore );
-               } else {
-                       $stores = array();
-               }
-
-               if ( count( $stores ) ) {
-                       $this->output( "Initialising external storage...\n" );
-                       global $wgDBuser, $wgDBpassword, $wgExternalServers;
-                       foreach ( $stores as $storeURL ) {
-                               $m = array();
-                               if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
-                                       continue;
-                               }
-
-                               $cluster = $m[1];
-
-                               # Hack
-                               $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
-                               $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
-
-                               $store = new ExternalStoreDB;
-                               $extdb =& $store->getMaster( $cluster );
-                               $extdb->query( "SET table_type=InnoDB" );
-                               $extdb->query( "CREATE DATABASE {$to}" );
-                               $extdb->query( "ALTER TABLE {$from}.blobs RENAME TO {$to}.blobs" );
-                               $extdb->selectDB( $from );
-                               $extdb->sourceFile( $this->getDir() . '/storage/blobs.sql' );
-                               $extdb->commit();
-                       }
-               }
-               $this->output( "done.\n" );
-       }
-}
-
-$maintClass = "RenameWiki";
-require_once( RUN_MAINTENANCE_IF_MAIN );