5 require_once( "commandLine.inc" );
6 require_once( "rebuildInterwiki.inc" );
7 require_once( "languages/Names.php" );
8 if ( count( $args ) != 3 ) {
9 wfDie( "Usage: php addwiki.php <language> <site> <dbname>\n" );
12 addWiki( $args[0], $args[1], $args[2] );
14 # -----------------------------------------------------------------
16 function addWiki( $lang, $site, $dbName )
18 global $IP, $wgLanguageNames, $wgDefaultExternalStore;
20 $name = $wgLanguageNames[$lang];
22 $dbw = wfGetDB( DB_WRITE
);
23 $common = "/home/wikipedia/common";
24 $maintenance = "$IP/maintenance";
26 print "Creating database $dbName for $lang.$site\n";
29 $dbw->query( "SET table_type=Innodb" );
30 $dbw->query( "CREATE DATABASE $dbName" );
31 $dbw->selectDB( $dbName );
33 print "Initialising tables\n";
34 dbsource( "$maintenance/tables.sql", $dbw );
35 dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
36 dbsource( "$IP/extensions/AntiSpoof/mysql/patch-antispoof.sql", $dbw );
37 dbsource( "$IP/extensions/CheckUser/cu_changes.sql", $dbw );
38 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
40 # Initialise external storage
41 if ( is_array( $wgDefaultExternalStore ) ) {
42 $stores = $wgDefaultExternalStore;
43 } elseif ( $stores ) {
44 $stores = array( $wgDefaultExternalStore );
48 if ( count( $stores ) ) {
49 require_once( 'ExternalStoreDB.php' );
50 print "Initialising external storage $store...\n";
51 global $wgDBuser, $wgDBpassword, $wgExternalServers;
52 foreach ( $stores as $storeURL ) {
54 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
61 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
62 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
64 $store = new ExternalStoreDB
;
65 $extdb =& $store->getMaster( $cluster );
66 $extdb->query( "SET table_type=InnoDB" );
67 $extdb->query( "CREATE DATABASE $dbName" );
68 $extdb->selectDB( $dbName );
69 dbsource( "$maintenance/storage/blobs.sql", $extdb );
70 $extdb->immediateCommit();
74 global $wgTitle, $wgArticle;
75 $wgTitle = Title
::newMainPage();
76 $wgArticle = new Article( $wgTitle );
77 $ucsite = ucfirst( $site );
79 $wgArticle->insertNewArticle( <<<EOT
80 ==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
82 * 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.
84 * If you would like to help translating the interface to this language, please do not translate here, but go to [[betawiki:|Betawiki]], a special wiki for translating the interface. That way everyone can use it on every wiki using the [[mw:|same software]].
86 * 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]].
89 <span class="plainlinks">
90 [http://www.wikipedia.org Wikipedia] |
91 [http://www.wiktionary.org Wiktonary] |
92 [http://www.wikibooks.org Wikibooks] |
93 [http://www.wikinews.org Wikinews] |
94 [http://www.wikiquote.org Wikiquote] |
95 [http://www.wikisource.org Wikisource]
96 [http://www.wikiversity.org Wikiversity]
99 See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
211 , '', false, false );
213 print "Adding to dblists\n";
216 $file = fopen( "$common/all.dblist", "a" );
217 fwrite( $file, "$dbName\n" );
220 # Update the sublists
221 system("cd $common && ./refresh-dblist");
223 print "Constructing interwiki SQL\n";
224 # Rebuild interwiki tables
225 $sql = getRebuildInterwikiSQL();
226 $tempname = tempnam( '/tmp', 'addwiki' );
227 $file = fopen( $tempname, 'w' );
229 wfDie( "Error, unable to open temporary file $tempname\n" );
231 fwrite( $file, $sql );
233 print "Sourcing interwiki SQL\n";
234 dbsource( $tempname, $dbw );
235 #unlink( $tempname );
237 # Create the upload dir
238 global $wgUploadDirectory;
239 if( file_exists( $wgUploadDirectory ) ) {
240 echo "$wgUploadDirectory already exists.\n";
242 echo "Creating $wgUploadDirectory...\n";
243 mkdir( $wgUploadDirectory, 0777 );
244 chmod( $wgUploadDirectory, 0777 );
247 print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";