12 require_once( "commandLine.inc" );
13 require_once( "rebuildInterwiki.inc" );
14 require_once( "languages/Names.php" );
15 if ( count( $args ) != 3 ) {
16 wfDie( "Usage: php addwiki.php <language> <site> <dbname>\n" );
19 addWiki( $args[0], $args[1], $args[2] );
21 # -----------------------------------------------------------------
23 function addWiki( $lang, $site, $dbName )
25 global $IP, $wgLanguageNames, $wgDefaultExternalStore;
27 $name = $wgLanguageNames[$lang];
29 $dbw = wfGetDB( DB_MASTER
);
30 $common = "/home/wikipedia/common";
31 $maintenance = "$IP/maintenance";
33 print "Creating database $dbName for $lang.$site\n";
36 $dbw->query( "SET table_type=Innodb" );
37 $dbw->query( "CREATE DATABASE $dbName" );
38 $dbw->selectDB( $dbName );
40 print "Initialising tables\n";
41 dbsource( "$maintenance/tables.sql", $dbw );
42 dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
43 dbsource( "$IP/extensions/AntiSpoof/mysql/patch-antispoof.sql", $dbw );
44 dbsource( "$IP/extensions/CheckUser/cu_changes.sql", $dbw );
45 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
47 # Initialise external storage
48 if ( is_array( $wgDefaultExternalStore ) ) {
49 $stores = $wgDefaultExternalStore;
50 } elseif ( $stores ) {
51 $stores = array( $wgDefaultExternalStore );
55 if ( count( $stores ) ) {
56 require_once( 'ExternalStoreDB.php' );
57 print "Initialising external storage $store...\n";
58 global $wgDBuser, $wgDBpassword, $wgExternalServers;
59 foreach ( $stores as $storeURL ) {
61 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
68 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
69 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
71 $store = new ExternalStoreDB
;
72 $extdb =& $store->getMaster( $cluster );
73 $extdb->query( "SET table_type=InnoDB" );
74 $extdb->query( "CREATE DATABASE $dbName" );
75 $extdb->selectDB( $dbName );
76 dbsource( "$maintenance/storage/blobs.sql", $extdb );
77 $extdb->immediateCommit();
81 global $wgTitle, $wgArticle;
82 $wgTitle = Title
::newMainPage();
83 $wgArticle = new Article( $wgTitle );
84 $ucsite = ucfirst( $site );
86 $wgArticle->insertNewArticle( <<<EOT
87 ==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
89 * 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.
91 * 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]].
93 * 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]].
96 <span class="plainlinks">
97 [http://www.wikipedia.org Wikipedia] |
98 [http://www.wiktionary.org Wiktonary] |
99 [http://www.wikibooks.org Wikibooks] |
100 [http://www.wikinews.org Wikinews] |
101 [http://www.wikiquote.org Wikiquote] |
102 [http://www.wikisource.org Wikisource]
103 [http://www.wikiversity.org Wikiversity]
106 See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
218 , '', false, false );
220 print "Adding to dblists\n";
223 $file = fopen( "$common/all.dblist", "a" );
224 fwrite( $file, "$dbName\n" );
227 # Update the sublists
228 system("cd $common && ./refresh-dblist");
230 print "Constructing interwiki SQL\n";
231 # Rebuild interwiki tables
232 $sql = getRebuildInterwikiSQL();
233 $tempname = tempnam( '/tmp', 'addwiki' );
234 $file = fopen( $tempname, 'w' );
236 wfDie( "Error, unable to open temporary file $tempname\n" );
238 fwrite( $file, $sql );
240 print "Sourcing interwiki SQL\n";
241 dbsource( $tempname, $dbw );
242 #unlink( $tempname );
244 # Create the upload dir
245 global $wgUploadDirectory;
246 if( file_exists( $wgUploadDirectory ) ) {
247 echo "$wgUploadDirectory already exists.\n";
249 echo "Creating $wgUploadDirectory...\n";
250 mkdir( $wgUploadDirectory, 0777 );
251 chmod( $wgUploadDirectory, 0777 );
254 print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";