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 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
39 # Initialise external storage
40 if ( is_array( $wgDefaultExternalStore ) ) {
41 $stores = $wgDefaultExternalStore;
42 } elseif ( $stores ) {
43 $stores = array( $wgDefaultExternalStore );
47 if ( count( $stores ) ) {
48 require_once( 'ExternalStoreDB.php' );
49 print "Initialising external storage $store...\n";
50 global $wgDBuser, $wgDBpassword, $wgExternalServers;
51 foreach ( $stores as $storeURL ) {
52 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
59 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
60 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
62 $store = new ExternalStoreDB
;
63 $extdb =& $store->getMaster( $cluster );
64 $extdb->query( "SET table_type=InnoDB" );
65 $extdb->query( "CREATE DATABASE $dbName" );
66 $extdb->selectDB( $dbName );
67 dbsource( "$maintenance/storage/blobs.sql", $extdb );
68 $extdb->immediateCommit();
72 $wgTitle = Title
::newMainPage();
73 $wgArticle = new Article( $wgTitle );
74 $ucsite = ucfirst( $site );
76 $wgArticle->insertNewArticle( "
77 ==This subdomain is reserved for the creation of a $ucsite in '''[[:en:{$name}|{$name}]]''' language==
79 If you can write in this language and want to collaborate in the creation of this encyclopedia then '''you''' can make it.
81 Go ahead. Translate this page and start working on your encyclopedia.
83 For help, see '''[[m:Help:How to start a new Wikipedia|how to start a new Wikipedia]]'''.
86 [http://meta.wikipedia.org Meta-Wikipedia] | [http://www.wiktionary.org Wikitonary] | [http://www.wikibooks.org Wikibooks] | [http://www.wikinews.org Wikinews] | [http://www.wikiquote.org Wikiquote] | [http://www.wikisource.org Wikisource]
88 See the [http://www.wikipedia.org Wikipedia portal] for other language Wikipedias.
196 ", '', false, false );
198 print "Adding to dblists\n";
201 $file = fopen( "$common/all.dblist", "a" );
202 fwrite( $file, "$dbName\n" );
205 # Update the sublists
206 system("cd $common && ./refresh-dblist");
208 print "Constructing interwiki SQL\n";
209 # Rebuild interwiki tables
210 $sql = getRebuildInterwikiSQL();
211 $tempname = tempnam( '/tmp', 'addwiki' );
212 $file = fopen( $tempname, 'w' );
214 wfDie( "Error, unable to open temporary file $tempname\n" );
216 fwrite( $file, $sql );
218 print "Sourcing interwiki SQL\n";
219 dbsource( $tempname, $dbw );
220 #unlink( $tempname );
222 # Create the upload dir
223 global $wgUploadDirectory;
224 if( file_exists( $wgUploadDirectory ) ) {
225 echo "$wgUploadDirectory already exists.\n";
227 echo "Creating $wgUploadDirectory...\n";
228 mkdir( $wgUploadDirectory, 0777 );
229 chmod( $wgUploadDirectory, 0777 );
232 print "Script ended. You now want to run sync-common-all to publish *dblist files (check them for duplicates first)\n";