Pascal Dreissen
2016-07-08 505fc4feb44bf9606f6ecc1f7bae897cf61446a3
commit | author | age
181529 1 <?php
L 2 /*
3 Copyright (c) 2007-2011, Till Brehm, projektfarm Gmbh and Oliver Vogel , Meins und Vogel
4 All rights reserved.
5
6 Redistribution and use in source and binary forms, with or without modification,
7 are permitted provided that the following conditions are met:
8
9     * Redistributions of source code must retain the above copyright notice,
10       this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright notice,
12       this list of conditions and the following disclaimer in the documentation
13       and/or other materials provided with the distribution.
14     * Neither the name of ISPConfig nor the names of its contributors
15       may be used to endorse or promote products derived from this software without
16       specific prior written permission.
17
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
27 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30 /*
31     ISPConfig 3 Set Rights. Tries to correct the rights of the clients if they are wrong
32 */
33
34 error_reporting(E_ALL|E_STRICT);
35
36 //** The banner on the command line
b1a6a5 37 echo "\n\n".str_repeat('-', 80)."\n";
181529 38 echo " _____ ___________   _____              __ _         ____
L 39 |_   _/  ___| ___ \ /  __ \            / _(_)       /__  \
40   | | \ `--.| |_/ / | /  \/ ___  _ __ | |_ _  __ _    _/ /
41   | |  `--. \  __/  | |    / _ \| '_ \|  _| |/ _` |  |_ |
42  _| |_/\__/ / |     | \__/\ (_) | | | | | | | (_| | ___\ \
43  \___/\____/\_|      \____/\___/|_| |_|_| |_|\__, | \____/
44                                               __/ |
45                                              |___/ ";
b1a6a5 46 echo "\n".str_repeat('-', 80)."\n";
MC 47 echo "\n\n>>This script tries to repair the client rights  \n\n";
181529 48
L 49 //** Include the library with the basic installer functions
b1a6a5 50 require_once 'lib/install.lib.php';
181529 51
L 52 //** Include the library with the basic updater functions
b1a6a5 53 require_once 'lib/update.lib.php';
181529 54
L 55 //** Include the base class of the installer class
b1a6a5 56 require_once 'lib/installer_base.lib.php';
181529 57
L 58 //** Ensure that current working directory is install directory
59 $cur_dir = getcwd();
60 if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n");
61
62 //** Get distribution identifier
63 $dist = get_distname();
64
b1a6a5 65 include_once "/usr/local/ispconfig/server/lib/config.inc.php";
181529 66 $conf_old = $conf;
L 67 unset($conf);
68
69 if($dist['id'] == '') die('Linux distribution or version not recognized.');
70
71 //** Include the distribution-specific installer class library and configuration
b1a6a5 72 if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once 'dist/lib/'.$dist['baseid'].'.lib.php';
MC 73 include_once 'dist/lib/'.$dist['id'].'.lib.php';
74 include_once 'dist/conf/'.$dist['id'].'.conf.php';
181529 75
L 76 //** Get hostname
77 exec('hostname -f', $tmp_out);
78 $conf['hostname'] = $tmp_out[0];
79 unset($tmp_out);
80
81 //* Check if this is a master / slave setup
82 $conf['mysql']['master_slave_setup'] = 'n';
83 if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) {
84     $conf['mysql']['master_slave_setup'] = 'y';
85 }
86
87 /*
88  * Try to read the DB-admin settings
89  */
b1a6a5 90 $clientdb_host   = '';
MC 91 $clientdb_user   = '';
92 $clientdb_password  = '';
93 include_once "/usr/local/ispconfig/server/lib/mysql_clientdb.conf";
181529 94 $conf["mysql"]["admin_user"] = $clientdb_user;
L 95 $conf["mysql"]["admin_password"] = $clientdb_password;
b1a6a5 96 $clientdb_host   = '';
MC 97 $clientdb_user   = '';
98 $clientdb_password  = '';
181529 99
L 100 //** There is a error if user for mysql admin_password if empty
101 if( empty($conf["mysql"]["admin_password"]) ) {
102     die("internal error - MYSQL-Root passord not known");
103 }
104
105 $inst = new installer();
106
107 //** Initialize the MySQL server connection
b1a6a5 108 include_once 'lib/mysql.lib.php';
181529 109
L 110 //* initialize the database
111 $inst->db = new db();
112
113 /*
114  * The next line is a bit tricky!
115  * At the automated update we have no connection to the master-db (we don't need it, because
116  * there are only TWO points, where this is needed)
117  * 1) update the rights --> the autoupdater sets the rights of all clients when the server is
118  *    autoupdated)
119  * 2) update the server-settings (is web installed, is mail installed) --> the autoupdates
120  *    doesn't change any of this settings, so there ist no need to update this.
121  * This means, the autoupdater did not need any connection to the master-db (only to the local bd
122  * of the master-server). To avoid any problems, we set the master-db to the local one.
123  */
124 $inst->dbmaster = $inst->db;
125
126 /*
127  * If it is NOT a master-slave - Setup then we are at the Master-DB. So set all rights
128 */
129 if($conf['mysql']['master_slave_setup'] != 'y') {
130     $inst->grant_master_database_rights(true);
131 }
132
133 echo "finished.\n";
134
135 ?>