00001 <?php
00010 $wgNoDBParam = true;
00011
00012 require_once( "commandLine.inc" );
00013 require_once( "rebuildInterwiki.inc" );
00014 require_once( "languages/Names.php" );
00015 if ( count( $args ) != 3 ) {
00016 wfDie( "Usage: php addwiki.php <language> <site> <dbname>\nThe site for Wikipedia is 'wikipedia'.\n" );
00017 }
00018
00019 addWiki( $args[0], $args[1], $args[2] );
00020
00021 # -----------------------------------------------------------------
00022
00023 function addWiki( $lang, $site, $dbName )
00024 {
00025 global $IP, $wgLanguageNames, $wgDefaultExternalStore;
00026
00027 if ( !isset( $wgLanguageNames[$lang] ) ) {
00028 print "Language $lang not found in \$wgLanguageNames\n";
00029 return;
00030 }
00031 $name = $wgLanguageNames[$lang];
00032
00033 $dbw = wfGetDB( DB_MASTER );
00034 $common = "/home/wikipedia/common";
00035 $maintenance = "$IP/maintenance";
00036
00037 print "Creating database $dbName for $lang.$site ($name)\n";
00038
00039 # Set up the database
00040 $dbw->query( "SET table_type=Innodb" );
00041 $dbw->query( "CREATE DATABASE $dbName" );
00042 $dbw->selectDB( $dbName );
00043
00044 print "Initialising tables\n";
00045 dbsource( "$maintenance/tables.sql", $dbw );
00046 dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
00047 dbsource( "$IP/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql", $dbw );
00048 dbsource( "$IP/extensions/CheckUser/cu_changes.sql", $dbw );
00049 dbsource( "$IP/extensions/CheckUser/cu_log.sql", $dbw );
00050 dbsource( "$IP/extensions/TitleKey/titlekey.sql", $dbw );
00051 dbsource( "$IP/extensions/Oversight/hidden.sql", $dbw );
00052 dbsource( "$IP/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql", $dbw );
00053
00054 $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
00055
00056 # Initialise external storage
00057 if ( is_array( $wgDefaultExternalStore ) ) {
00058 $stores = $wgDefaultExternalStore;
00059 } elseif ( $stores ) {
00060 $stores = array( $wgDefaultExternalStore );
00061 } else {
00062 $stores = array();
00063 }
00064 if ( count( $stores ) ) {
00065 require_once( 'ExternalStoreDB.php' );
00066 print "Initialising external storage $store...\n";
00067 global $wgDBuser, $wgDBpassword, $wgExternalServers;
00068 foreach ( $stores as $storeURL ) {
00069 $m = array();
00070 if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
00071 continue;
00072 }
00073
00074 $cluster = $m[1];
00075
00076 # Hack
00077 $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
00078 $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
00079
00080 $store = new ExternalStoreDB;
00081 $extdb =& $store->getMaster( $cluster );
00082 $extdb->query( "SET table_type=InnoDB" );
00083 $extdb->query( "CREATE DATABASE $dbName" );
00084 $extdb->selectDB( $dbName );
00085 dbsource( "$maintenance/storage/blobs.sql", $extdb );
00086 $extdb->immediateCommit();
00087 }
00088 }
00089
00090 global $wgTitle, $wgArticle;
00091 $wgTitle = Title::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) );
00092 print "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n";
00093 $wgArticle = new Article( $wgTitle );
00094 $ucsite = ucfirst( $site );
00095
00096 $wgArticle->insertNewArticle( <<<EOT
00097 ==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
00098
00099 * 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.
00100
00101 * 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]].
00102
00103 * 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]].
00104
00105 == Sister projects ==
00106 <span class="plainlinks">
00107 [http://www.wikipedia.org Wikipedia] |
00108 [http://www.wiktionary.org Wiktonary] |
00109 [http://www.wikibooks.org Wikibooks] |
00110 [http://www.wikinews.org Wikinews] |
00111 [http://www.wikiquote.org Wikiquote] |
00112 [http://www.wikisource.org Wikisource]
00113 [http://www.wikiversity.org Wikiversity]
00114 </span>
00115
00116 See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
00117
00118 [[aa:]]
00119 [[af:]]
00120 [[als:]]
00121 [[ar:]]
00122 [[de:]]
00123 [[en:]]
00124 [[as:]]
00125 [[ast:]]
00126 [[ay:]]
00127 [[az:]]
00128 [[bcl:]]
00129 [[be:]]
00130 [[bg:]]
00131 [[bn:]]
00132 [[bo:]]
00133 [[bs:]]
00134 [[cs:]]
00135 [[co:]]
00136 [[cs:]]
00137 [[cy:]]
00138 [[da:]]
00139 [[el:]]
00140 [[eo:]]
00141 [[es:]]
00142 [[et:]]
00143 [[eu:]]
00144 [[fa:]]
00145 [[fi:]]
00146 [[fr:]]
00147 [[fy:]]
00148 [[ga:]]
00149 [[gl:]]
00150 [[gn:]]
00151 [[gu:]]
00152 [[he:]]
00153 [[hi:]]
00154 [[hr:]]
00155 [[hsb:]]
00156 [[hy:]]
00157 [[ia:]]
00158 [[id:]]
00159 [[is:]]
00160 [[it:]]
00161 [[ja:]]
00162 [[ka:]]
00163 [[kk:]]
00164 [[km:]]
00165 [[kn:]]
00166 [[ko:]]
00167 [[ks:]]
00168 [[ku:]]
00169 [[ky:]]
00170 [[la:]]
00171 [[ln:]]
00172 [[lo:]]
00173 [[lt:]]
00174 [[lv:]]
00175 [[hu:]]
00176 [[mi:]]
00177 [[mk:]]
00178 [[ml:]]
00179 [[mn:]]
00180 [[mr:]]
00181 [[ms:]]
00182 [[mt:]]
00183 [[my:]]
00184 [[na:]]
00185 [[nah:]]
00186 [[nds:]]
00187 [[ne:]]
00188 [[nl:]]
00189 [[no:]]
00190 [[oc:]]
00191 [[om:]]
00192 [[pa:]]
00193 [[pl:]]
00194 [[ps:]]
00195 [[pt:]]
00196 [[qu:]]
00197 [[ro:]]
00198 [[ru:]]
00199 [[sa:]]
00200 [[si:]]
00201 [[sk:]]
00202 [[sl:]]
00203 [[sq:]]
00204 [[sr:]]
00205 [[sv:]]
00206 [[sw:]]
00207 [[ta:]]
00208 [[te:]]
00209 [[tg:]]
00210 [[th:]]
00211 [[tk:]]
00212 [[tl:]]
00213 [[tr:]]
00214 [[tt:]]
00215 [[ug:]]
00216 [[uk:]]
00217 [[ur:]]
00218 [[uz:]]
00219 [[vi:]]
00220 [[vo:]]
00221 [[xh:]]
00222 [[yo:]]
00223 [[za:]]
00224 [[zh:]]
00225 [[zu:]]
00226
00227 EOT
00228 , '', false, false );
00229
00230 print "Adding to dblists\n";
00231
00232 # Add to dblist
00233 $file = fopen( "$common/all.dblist", "a" );
00234 fwrite( $file, "$dbName\n" );
00235 fclose( $file );
00236
00237 # Update the sublists
00238 shell_exec("cd $common && ./refresh-dblist");
00239
00240 #print "Constructing interwiki SQL\n";
00241 # Rebuild interwiki tables
00242 #passthru( '/home/wikipedia/conf/interwiki/update' );
00243
00244 print "Script ended. You still have to:
00245 * Add any required settings in InitialiseSettings.php
00246 * Run sync-common-all
00247 * Run /home/wikipedia/conf/interwiki/update
00248 ";
00249 }
00250