]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - maintenance/addwiki.php
MediaWiki 1.14.0
[autoinstallsdev/mediawiki.git] / maintenance / addwiki.php
1 <?php
2 /**
3  * Add a new wiki
4  * Wikimedia specific!
5  *
6  * @file
7  * @ingroup Maintenance
8  */
9
10 $wgNoDBParam = true;
11
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>\nThe site for Wikipedia is 'wikipedia'.\n" );
17 }
18
19 addWiki( $args[0], $args[1], $args[2] );
20
21 # -----------------------------------------------------------------
22
23 function addWiki( $lang, $site, $dbName )
24 {
25         global $IP, $wgLanguageNames, $wgDefaultExternalStore;
26
27         if ( !isset( $wgLanguageNames[$lang] ) ) {
28                 print "Language $lang not found in \$wgLanguageNames\n";
29                 return;
30         }
31         $name = $wgLanguageNames[$lang];
32
33         $dbw = wfGetDB( DB_MASTER );
34         $common = "/home/wikipedia/common";
35         $maintenance = "$IP/maintenance";
36
37         print "Creating database $dbName for $lang.$site ($name)\n";
38         
39         # Set up the database
40         $dbw->query( "SET table_type=Innodb" );
41         $dbw->query( "CREATE DATABASE $dbName" );
42         $dbw->selectDB( $dbName );
43
44         print "Initialising tables\n";
45         dbsource( "$maintenance/tables.sql", $dbw );
46         dbsource( "$IP/extensions/OAI/update_table.sql", $dbw );
47         dbsource( "$IP/extensions/AntiSpoof/sql/patch-antispoof.mysql.sql", $dbw );
48         dbsource( "$IP/extensions/CheckUser/cu_changes.sql", $dbw );
49         dbsource( "$IP/extensions/CheckUser/cu_log.sql", $dbw );
50         dbsource( "$IP/extensions/TitleKey/titlekey.sql", $dbw );
51         dbsource( "$IP/extensions/Oversight/hidden.sql", $dbw );
52         dbsource( "$IP/extensions/GlobalBlocking/localdb_patches/setup-global_block_whitelist.sql", $dbw );
53
54         $dbw->query( "INSERT INTO site_stats(ss_row_id) VALUES (1)" );
55
56         # Initialise external storage
57         if ( is_array( $wgDefaultExternalStore ) ) {
58                 $stores = $wgDefaultExternalStore;
59         } elseif ( $stores ) {
60                 $stores = array( $wgDefaultExternalStore );
61         } else {
62                 $stores = array();
63         }
64         if ( count( $stores ) ) {
65                 require_once( 'ExternalStoreDB.php' );
66                 print "Initialising external storage $store...\n";
67                 global $wgDBuser, $wgDBpassword, $wgExternalServers;
68                 foreach ( $stores as $storeURL ) {
69                         $m = array();
70                         if ( !preg_match( '!^DB://(.*)$!', $storeURL, $m ) ) {
71                                 continue;
72                         }
73                         
74                         $cluster = $m[1];
75                         
76                         # Hack
77                         $wgExternalServers[$cluster][0]['user'] = $wgDBuser;
78                         $wgExternalServers[$cluster][0]['password'] = $wgDBpassword;
79                         
80                         $store = new ExternalStoreDB;
81                         $extdb =& $store->getMaster( $cluster );
82                         $extdb->query( "SET table_type=InnoDB" );
83                         $extdb->query( "CREATE DATABASE $dbName" );
84                         $extdb->selectDB( $dbName );
85                         dbsource( "$maintenance/storage/blobs.sql", $extdb );
86                         $extdb->immediateCommit();
87                 }
88         }
89
90         global $wgTitle, $wgArticle;
91         $wgTitle = Title::newFromText( wfMsgWeirdKey( "mainpage/$lang" ) );
92         print "Writing main page to " . $wgTitle->getPrefixedDBkey() . "\n";
93         $wgArticle = new Article( $wgTitle );
94         $ucsite = ucfirst( $site );
95
96         $wgArticle->insertNewArticle( <<<EOT
97 ==This subdomain is reserved for the creation of a [[wikimedia:Our projects|$ucsite]] in '''[[w:en:{$name}|{$name}]]''' language==
98
99 * 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.
100
101 * 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]].
102
103 * 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]].
104
105 == Sister projects ==
106 <span class="plainlinks">
107 [http://www.wikipedia.org Wikipedia] |
108 [http://www.wiktionary.org Wiktonary] |
109 [http://www.wikibooks.org Wikibooks] |
110 [http://www.wikinews.org Wikinews] |
111 [http://www.wikiquote.org Wikiquote] |
112 [http://www.wikisource.org Wikisource]
113 [http://www.wikiversity.org Wikiversity]
114 </span>
115
116 See Wikimedia's [[m:|Meta-Wiki]] for the coordination of these projects.
117
118 [[aa:]]
119 [[af:]]
120 [[als:]]
121 [[ar:]]
122 [[de:]]
123 [[en:]]
124 [[as:]]
125 [[ast:]]
126 [[ay:]]
127 [[az:]]
128 [[bcl:]]
129 [[be:]]
130 [[bg:]]
131 [[bn:]]
132 [[bo:]]
133 [[bs:]]
134 [[cs:]]
135 [[co:]]
136 [[cs:]]
137 [[cy:]]
138 [[da:]]
139 [[el:]]
140 [[eo:]]
141 [[es:]]
142 [[et:]]
143 [[eu:]]
144 [[fa:]]
145 [[fi:]]
146 [[fr:]]
147 [[fy:]]
148 [[ga:]]
149 [[gl:]]
150 [[gn:]]
151 [[gu:]]
152 [[he:]]
153 [[hi:]]
154 [[hr:]]
155 [[hsb:]]
156 [[hy:]]
157 [[ia:]]
158 [[id:]]
159 [[is:]]
160 [[it:]]
161 [[ja:]]
162 [[ka:]]
163 [[kk:]]
164 [[km:]]
165 [[kn:]]
166 [[ko:]]
167 [[ks:]]
168 [[ku:]]
169 [[ky:]]
170 [[la:]]
171 [[ln:]]
172 [[lo:]]
173 [[lt:]]
174 [[lv:]]
175 [[hu:]]
176 [[mi:]]
177 [[mk:]]
178 [[ml:]]
179 [[mn:]]
180 [[mr:]]
181 [[ms:]]
182 [[mt:]]
183 [[my:]]
184 [[na:]]
185 [[nah:]]
186 [[nds:]]
187 [[ne:]]
188 [[nl:]]
189 [[no:]]
190 [[oc:]]
191 [[om:]]
192 [[pa:]]
193 [[pl:]]
194 [[ps:]]
195 [[pt:]]
196 [[qu:]]
197 [[ro:]]
198 [[ru:]]
199 [[sa:]]
200 [[si:]]
201 [[sk:]]
202 [[sl:]]
203 [[sq:]]
204 [[sr:]]
205 [[sv:]]
206 [[sw:]]
207 [[ta:]]
208 [[te:]]
209 [[tg:]]
210 [[th:]]
211 [[tk:]]
212 [[tl:]]
213 [[tr:]]
214 [[tt:]]
215 [[ug:]]
216 [[uk:]]
217 [[ur:]]
218 [[uz:]]
219 [[vi:]]
220 [[vo:]]
221 [[xh:]]
222 [[yo:]]
223 [[za:]]
224 [[zh:]]
225 [[zu:]]
226
227 EOT
228 , '', false, false );
229
230         print "Adding to dblists\n";
231
232         # Add to dblist
233         $file = fopen( "$common/all.dblist", "a" );
234         fwrite( $file, "$dbName\n" );
235         fclose( $file );
236
237         # Update the sublists
238         shell_exec("cd $common && ./refresh-dblist");
239
240         #print "Constructing interwiki SQL\n";
241         # Rebuild interwiki tables
242         #passthru( '/home/wikipedia/conf/interwiki/update' );
243
244         print "Script ended. You still have to:
245 * Add any required settings in InitialiseSettings.php
246 * Run sync-common-all
247 * Run /home/wikipedia/conf/interwiki/update
248 ";
249 }
250