Start managing output and input context from special pages themselves instead of...
[lhc/web/wiklou.git] / maintenance / ourusers.php
1 <?php
2 /**
3 * Wikimedia specific
4 *
5 * This script generates SQL used to update MySQL users on a hardcoded
6 * list of hosts. It takes care of setting the wikiuser for every
7 * database as well as setting up wikiadmin.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @todo document
25 * @file
26 * @ingroup Maintenance
27 * @ingroup Wikimedia
28 */
29
30 /** */
31 $wikiuser_pass = `wikiuser_pass`;
32 $wikiadmin_pass = `wikiadmin_pass`;
33 $nagios_pass = `nagios_sql_pass`;
34
35 $hosts = array(
36 'localhost',
37 '10.0.%',
38 '66.230.200.%',
39 '208.80.152.%',
40 );
41
42 $databases = array(
43 '%wik%',
44 'centralauth',
45 );
46
47 print "/*!40100 set old_passwords=1 */;\n";
48 print "/*!40100 set global old_passwords=1 */;\n";
49
50 foreach ( $hosts as $host ) {
51 print "--\n-- $host\n--\n";
52 print "\n-- wikiuser\n\n";
53 print "GRANT REPLICATION CLIENT,PROCESS ON *.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
54 print "GRANT ALL PRIVILEGES ON `boardvote%`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
55 foreach ( $databases as $db ) {
56 print "GRANT SELECT, INSERT, UPDATE, DELETE ON `$db`.* TO 'wikiuser'@'$host' IDENTIFIED BY '$wikiuser_pass';\n";
57 }
58
59 print "\n-- wikiadmin\n\n";
60 print "GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'wikiadmin'@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
61 print "GRANT ALL PRIVILEGES ON `boardvote%`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
62 foreach ( $databases as $db ) {
63 print "GRANT ALL PRIVILEGES ON `$db`.* TO wikiadmin@'$host' IDENTIFIED BY '$wikiadmin_pass';\n";
64 }
65 print "\n-- nagios\n\n";
66 print "GRANT REPLICATION CLIENT ON *.* TO 'nagios'@'$host' IDENTIFIED BY '$nagios_pass';\n";
67
68 print "\n";
69 }
70