From d89ea9d33dddb5fd2d3809ee38bd256e57570582 Mon Sep 17 00:00:00 2001 From: "Ap.Muthu" Date: Tue, 9 Apr 2013 03:25:29 +0530 Subject: [PATCH] Quick Install Script Improvements -When using the contrib AutoInstaller to install on pre-created db -Check User DB connection before using root user -AutoInstaller Examples of Use for OpenVZ added -New cgi variable "no_root_db_access" explicitly clarifies cloning/migration installs -Fixed indentation and removed tabs in Quick Installer Fix. -4 spaces first indent, 2 spaces each indent thereafter on same line. -Refactored Quick Install Fix -Now allows Cloning / Migration on pre-created and pre-configured login/pass/dbname --- contrib/util/installScripts/InstallerAuto.php | 38 +++++++----- library/classes/Installer.class.php | 88 +++++++++++++++------------ 2 files changed, 71 insertions(+), 55 deletions(-) diff --git a/contrib/util/installScripts/InstallerAuto.php b/contrib/util/installScripts/InstallerAuto.php index 95a40471d..dfc06098f 100644 --- a/contrib/util/installScripts/InstallerAuto.php +++ b/contrib/util/installScripts/InstallerAuto.php @@ -42,6 +42,8 @@ // Advanced option of multi site module to allow cloning/mirroring of another local site. // clone_database -> if set to anything, then will clone database from source_site_id () // Advanced option of multi site module to allow cloning/mirroring of another local database. +// no_root_db_access -> if set to anything, will use pre-created and pre-configured login/pass/dbname and +// will disable cloning / migration since that generally requires root access to the db // development_translations -> If set to anything, will then download and use the development set (updated daily) // of translations from the github repository. // @@ -66,6 +68,9 @@ // php -f InstallerAuto.php login=openemr2 pass=openemr2 dbname=openemr2 site=default2 source_site_id=default clone_database=yes // d. Can continue installing new instances as needed ... // php -f InstallerAuto.php login=openemr3 pass=openemr3 dbname=openemr3 site=default3 source_site_id=default clone_database=yes +// 6) Provide pre-created database and restricted privilege user access credentials - example from Planettel.com.sg Proxmox OpenVZ Template +// (otherwise use default configuration settings - do not use for cloning / migration) +// php -f /var/www/openemr/contrib/util/installScripts/InstallerAuto.php no_root_db_access=1 iuserpass=oemr123 login=oemrusr pass=${UPASSWD} > /dev/null 2>&1 // // This exit is to avoid malicious use of this script. @@ -75,22 +80,23 @@ require_once(dirname(__FILE__).'/../../../library/classes/Installer.class.php'); // Set up default configuration settings $installSettings = array(); -$installSettings['iuser'] = 'admin'; -$installSettings['iuname'] = 'Administrator'; -$installSettings['iuserpass'] = 'pass'; -$installSettings['igroup'] = 'Default'; -$installSettings['server'] = 'localhost'; // mysql server -$installSettings['loginhost'] = 'localhost'; // php/apache server -$installSettings['port'] = '3306'; -$installSettings['root'] = 'root'; -$installSettings['rootpass'] = 'BLANK'; -$installSettings['login'] = 'openemr'; -$installSettings['pass'] = 'openemr'; -$installSettings['dbname'] = 'openemr'; -$installSettings['collate'] = 'utf8_general_ci'; -$installSettings['site'] = 'default'; -$installSettings['source_site_id'] = 'BLANK'; -$installSettings['clone_database'] = 'BLANK'; +$installSettings['iuser'] = 'admin'; +$installSettings['iuname'] = 'Administrator'; +$installSettings['iuserpass'] = 'pass'; +$installSettings['igroup'] = 'Default'; +$installSettings['server'] = 'localhost'; // mysql server +$installSettings['loginhost'] = 'localhost'; // php/apache server +$installSettings['port'] = '3306'; +$installSettings['root'] = 'root'; +$installSettings['rootpass'] = 'BLANK'; +$installSettings['login'] = 'openemr'; +$installSettings['pass'] = 'openemr'; +$installSettings['dbname'] = 'openemr'; +$installSettings['collate'] = 'utf8_general_ci'; +$installSettings['site'] = 'default'; +$installSettings['source_site_id'] = 'BLANK'; +$installSettings['clone_database'] = 'BLANK'; +$installSettings['no_root_db_access'] = 'BLANK'; $installSettings['development_translations'] = 'BLANK'; // Collect parameters(if exist) for installation configuration settings diff --git a/library/classes/Installer.class.php b/library/classes/Installer.class.php index a22790531..02a7d7b67 100644 --- a/library/classes/Installer.class.php +++ b/library/classes/Installer.class.php @@ -10,22 +10,23 @@ class Installer // Installation variables // For a good explanation of these variables, see documentation in // the contrib/util/installScripts/InstallerAuto.php file. - $this->iuser = $cgi_variables['iuser']; - $this->iuserpass = $cgi_variables['iuserpass']; - $this->iuname = $cgi_variables['iuname']; - $this->igroup = $cgi_variables['igroup']; - $this->server = $cgi_variables['server']; // mysql server (usually localhost) - $this->loginhost = $cgi_variables['loginhost']; // php/apache server (usually localhost) - $this->port = $cgi_variables['port']; - $this->root = $cgi_variables['root']; - $this->rootpass = $cgi_variables['rootpass']; - $this->login = $cgi_variables['login']; - $this->pass = $cgi_variables['pass']; - $this->dbname = $cgi_variables['dbname']; - $this->collate = $cgi_variables['collate']; - $this->site = $cgi_variables['site']; - $this->source_site_id = $cgi_variables['source_site_id']; - $this->clone_database = $cgi_variables['clone_database']; + $this->iuser = $cgi_variables['iuser']; + $this->iuserpass = $cgi_variables['iuserpass']; + $this->iuname = $cgi_variables['iuname']; + $this->igroup = $cgi_variables['igroup']; + $this->server = $cgi_variables['server']; // mysql server (usually localhost) + $this->loginhost = $cgi_variables['loginhost']; // php/apache server (usually localhost) + $this->port = $cgi_variables['port']; + $this->root = $cgi_variables['root']; + $this->rootpass = $cgi_variables['rootpass']; + $this->login = $cgi_variables['login']; + $this->pass = $cgi_variables['pass']; + $this->dbname = $cgi_variables['dbname']; + $this->collate = $cgi_variables['collate']; + $this->site = $cgi_variables['site']; + $this->source_site_id = $cgi_variables['source_site_id']; + $this->clone_database = $cgi_variables['clone_database']; + $this->no_root_db_access = $cgi_variables['no_root_db_access']; // no root access to database. user/privileges pre-configured $this->development_translations = $cgi_variables['development_translations']; // Make this true for IPPF. @@ -356,34 +357,43 @@ $config = 1; ///////////// if ( ! $this->password_is_valid() ) { return False; } - // Connect to mysql via root user - if (! $this->root_database_connection() ) { - return False; - } - // Create the dumpfile - // (applicable if cloning from another database) - if (! empty($this->clone_database)) { - if ( ! $this->create_dumpfiles() ) { + if (! $this->no_root_db_access) { + // Connect to mysql via root user + if (! $this->root_database_connection() ) { return False; } - } - // Create the site directory - // (applicable if mirroring another local site) - if ( ! empty($this->source_site_id) ) { - if ( ! $this->create_site_directory() ) { - return False; + // Create the dumpfile + // (applicable if cloning from another database) + if (! empty($this->clone_database)) { + if ( ! $this->create_dumpfiles() ) { + return False; + } } - } - // Create the mysql database - if ( ! $this->create_database()) { - return False; - } - // Grant user privileges to the mysql database - if ( ! $this->grant_privileges() ) { - return False; + // Create the site directory + // (applicable if mirroring another local site) + if ( ! empty($this->source_site_id) ) { + if ( ! $this->create_site_directory() ) { + return False; + } + } + $this->disconnect(); + if (! $this->user_database_connection()) { + // Re-connect to mysql via root user + if (! $this->root_database_connection() ) { + return False; + } + // Create the mysql database + if ( ! $this->create_database()) { + return False; + } + // Grant user privileges to the mysql database + if ( ! $this->grant_privileges() ) { + return False; + } + } + $this->disconnect(); } // Connect to mysql via created user - $this->disconnect(); if ( ! $this->user_database_connection() ) { return False; } -- 2.11.4.GIT