From 432971b9b6ee3b19b49710f89f428658722608d6 Mon Sep 17 00:00:00 2001 From: vogelor Date: Sun, 15 May 2011 09:53:31 +0000 Subject: [PATCH] added a "tool" to re-set the database rights at the master-db --- install/setrights.php | 135 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 install/setrights.php diff --git a/install/setrights.php b/install/setrights.php new file mode 100644 index 0000000000..89e2077a3a --- /dev/null +++ b/install/setrights.php @@ -0,0 +1,135 @@ +>This script tries to repair the client rights \n\n"; + +//** Include the library with the basic installer functions +require_once('lib/install.lib.php'); + +//** Include the library with the basic updater functions +require_once('lib/update.lib.php'); + +//** Include the base class of the installer class +require_once('lib/installer_base.lib.php'); + +//** Ensure that current working directory is install directory +$cur_dir = getcwd(); +if(realpath(dirname(__FILE__)) != $cur_dir) die("Please run installation/update from _inside_ the install directory!\n"); + +//** Get distribution identifier +$dist = get_distname(); + +include_once("/usr/local/ispconfig/server/lib/config.inc.php"); +$conf_old = $conf; +unset($conf); + +if($dist['id'] == '') die('Linux distribution or version not recognized.'); + +//** Include the distribution-specific installer class library and configuration +if(is_file('dist/lib/'.$dist['baseid'].'.lib.php')) include_once('dist/lib/'.$dist['baseid'].'.lib.php'); +include_once('dist/lib/'.$dist['id'].'.lib.php'); +include_once('dist/conf/'.$dist['id'].'.conf.php'); + +//** Get hostname +exec('hostname -f', $tmp_out); +$conf['hostname'] = $tmp_out[0]; +unset($tmp_out); + +//* Check if this is a master / slave setup +$conf['mysql']['master_slave_setup'] = 'n'; +if($conf["mysql"]["master_host"] != '' && $conf["mysql"]["host"] != $conf["mysql"]["master_host"]) { + $conf['mysql']['master_slave_setup'] = 'y'; +} + +/* + * Try to read the DB-admin settings + */ +$clientdb_host = ''; +$clientdb_user = ''; +$clientdb_password = ''; +include_once("/usr/local/ispconfig/server/lib/mysql_clientdb.conf"); +$conf["mysql"]["admin_user"] = $clientdb_user; +$conf["mysql"]["admin_password"] = $clientdb_password; +$clientdb_host = ''; +$clientdb_user = ''; +$clientdb_password = ''; + +//** There is a error if user for mysql admin_password if empty +if( empty($conf["mysql"]["admin_password"]) ) { + die("internal error - MYSQL-Root passord not known"); +} + +$inst = new installer(); + +//** Initialize the MySQL server connection +include_once('lib/mysql.lib.php'); + +//* initialize the database +$inst->db = new db(); + +/* + * The next line is a bit tricky! + * At the automated update we have no connection to the master-db (we don't need it, because + * there are only TWO points, where this is needed) + * 1) update the rights --> the autoupdater sets the rights of all clients when the server is + * autoupdated) + * 2) update the server-settings (is web installed, is mail installed) --> the autoupdates + * doesn't change any of this settings, so there ist no need to update this. + * This means, the autoupdater did not need any connection to the master-db (only to the local bd + * of the master-server). To avoid any problems, we set the master-db to the local one. + */ +$inst->dbmaster = $inst->db; + +/* + * If it is NOT a master-slave - Setup then we are at the Master-DB. So set all rights +*/ +if($conf['mysql']['master_slave_setup'] != 'y') { + $inst->grant_master_database_rights(true); +} + +echo "finished.\n"; + +?> -- GitLab