3 * @defgroup Wikimedia Wikimedia
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 * http://www.gnu.org/copyleft/gpl.html
26 * @ingroup Maintenance
30 require_once( dirname(__FILE__
) . '/Maintenance.php' );
32 class AddWiki
extends Maintenance
{
33 public function __construct() {
34 parent
::__construct();
35 $this->mDescription
= "Add a new wiki to the family. Wikimedia specific!";
36 $this->addArg( 'language', 'Language code of new site' );
37 $this->addArg( 'site', 'Type of site' );
38 $this->addArg( 'dbname', 'Name of database to create' );
41 protected function getDbType() {
42 return Maintenance
::DB_ADMIN
;
45 public function execute() {
46 global $IP, $wgLanguageNames, $wgDefaultExternalStore, $wgNoDBParam;
49 $lang = $this->getArg(0);
50 $site = $this->getArg(1);
51 $dbName = $this->getArg(2);
53 if ( !isset( $wgLanguageNames[$lang] ) ) {
54 $this->error( "Language $lang not found in \$wgLanguageNames", true );
56 $name = $wgLanguageNames[$lang];
58 $dbw = wfGetDB( DB_MASTER
);
59 $common = "/home/wikipedia/common";
61 $this->output( "Creating database $dbName for $lang.$site ($name)\n" );
64 $dbw->query( "SET table_type=Innodb" );
65 $dbw->query( "CREATE DATABASE $dbName" );
66 $dbw->selectDB( $dbName );
68 $this->output( "Initialising tables\n" );
69 $dbw->sourceFile( $this->getDir() . '/tables.sql' );
70 $dbw->sourceFile( "$IP/extensions/OAI/update_table.sql" );
71 $dbw->sourceFile( "$IP/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql" );
72 $dbw->sourceFile( "$IP/extensions/CheckUser/cu_changes.sql" );
73 $dbw->sourceFile( "$IP/extensions/CheckUser/cu_log.sql" );
74 $dbw->sourceFile( "$IP/extensions/TitleKey/titlekey.sql" );
75 $dbw->sourceFile( "$IP/extensions/Oversight/hidden.sql" );
76 $dbw->sourceFile( "$IP/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql" );
77 $dbw->sourceFile( "$IP/extensions/AbuseFilter/abusefilter.tables.sql" );
78 $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/PrefStats/PrefStats.sql" );
79 $dbw->sourceFile( "$IP/extensions/ProofreadPage/ProofreadPage.sql" );
80 $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/ClickTracking/ClickTrackingEvents.sql" );
81 $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql" );
82 $dbw->sourceFile( "$IP/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql" );
84 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
86 # Initialise external storage
87 if ( is_array( $wgDefaultExternalStore ) ) {
88 $stores = $wgDefaultExternalStore;
89 } elseif ( $stores ) {
90 $stores = array( $wgDefaultExternalStore );
94 if ( count( $stores ) ) {
95 global $wgDBuser, $wgDBpassword, $wgExternalServers;
96 foreach ( $stores as $storeURL ) {
98 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
103 $this->output( "Initialising external storage $cluster...\n" );
106 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
107 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
109 $store = new ExternalStoreDB
;
110 $extdb = $store->getMaster( $cluster );
111 $extdb->query( "SET table_type=InnoDB" );
112 $extdb->query( "CREATE DATABASE $dbName" );
113 $extdb->selectDB( $dbName );
116 $blobsTable = $store->getTable( $extdb );
117 $sedCmd = "sed s/blobs\\\\\\>/$blobsTable/ " . $this->getDir() . "/storage/blobs.sql";
118 $blobsFile = popen( $sedCmd, 'r' );
119 $extdb->sourceStream( $blobsFile );
120 pclose( $blobsFile );
125 global $wgTitle, $wgArticle;
126 $wgTitle = Title
::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) );
127 $this->output( "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n" );
128 $wgArticle = new Article( $wgTitle );
129 $ucsite = ucfirst( $site );
131 $wgArticle->insertNewArticle( $this->getFirstArticle( $ucsite, $name ), '', false, false );
133 $this->output( "Adding to dblists\n" );
136 $file = fopen( "$common/all.dblist", "a" );
137 fwrite( $file, "$dbName\n" );
140 # Update the sublists
141 shell_exec("cd $common && ./refresh-dblist");
143 #print "Constructing interwiki SQL\n";
144 # Rebuild interwiki tables
145 #passthru( '/home/wikipedia/conf/interwiki/update' );
147 $this->output( "Script ended. You still have to:
148 * Add any required settings in InitialiseSettings.php
149 * Run sync-common-all
150 * Run /home/wikipedia/conf/interwiki/update
154 private function getFirstArticle( $ucsite, $name ) {
156 ==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
158 * Please '''do not start editing''' this new site. This site has a test project on the [[incubator:|Wikimedia Incubator]] (or on the [[betawikiversity:|BetaWikiversity]] or on the [[oldwikisource:|Old Wikisource]]) and it will be imported to here.
160 * If you would like to help translating the interface to this language, please do not translate here, but go to [[translatewiki:|translatewiki]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].
162 * 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]].
164 == Sister projects ==
165 <span class="plainlinks">
166 [http://www.wikipedia.org Wikipedia] |
167 [http://www.wiktionary.org Wiktonary] |
168 [http://www.wikibooks.org Wikibooks] |
169 [http://www.wikinews.org Wikinews] |
170 [http://www.wikiquote.org Wikiquote] |
171 [http://www.wikisource.org Wikisource]
172 [http://www.wikiversity.org Wikiversity]
175 See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
453 $maintClass = "AddWiki";
454 require_once( DO_MAINTENANCE
);