Skip to content
Browse files

MDL-29046 use of install/distrolib.php in the CLI installer

Signed-off-by: Aleksey Avdeev <solo@altlinux.ru>
  • Loading branch information...
1 parent 9334f3d commit b0bc0bed50bd81d71788a68476eb9c5a0ac61a15 @solooboroten solooboroten committed with stronk7
Showing with 18 additions and 5 deletions.
  1. +18 −5 admin/cli/install.php
View
23 admin/cli/install.php
@@ -79,6 +79,16 @@
"; //TODO: localize, mark as needed in install - to be translated later when everything is finished
+// distro specific customisation
+$distrolibfile = dirname(dirname(dirname(__FILE__))).'/install/distrolib.php';
+$distro = null;
+if (file_exists($distrolibfile)) {
+ require_once($distrolibfile);
+ if (function_exists('distro_get_config')) {
+ $distro = distro_get_config();
+ }
+}
+
// Nothing to do if config.php exists
$configfile = dirname(dirname(dirname(__FILE__))).'/config.php';
if (file_exists($configfile)) {
@@ -130,7 +140,7 @@
$CFG->libdir = "$CFG->dirroot/lib";
$CFG->wwwroot = "http://localhost";
$CFG->httpswwwroot = $CFG->wwwroot;
-$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata');
+$CFG->dataroot = empty($distro->dataroot) ? str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'): $distro->dataroot; // initialised later after including libs or by distro
$CFG->docroot = 'http://docs.moodle.org';
$CFG->running_installer = true;
$CFG->early_install_lang = true;
@@ -178,14 +188,14 @@
// now get cli options
list($options, $unrecognized) = cli_get_params(
array(
- 'chmod' => '2777',
+ 'chmod' => isset($distro->directorypermissions) ? sprintf('%04o',$distro->directorypermissions) : '2777', // let distros set dir permissions
'lang' => $CFG->lang,
'wwwroot' => '',
'dataroot' => $CFG->dataroot,
- 'dbtype' => $defaultdb,
- 'dbhost' => 'localhost',
+ 'dbtype' => empty($distro->dbtype) ? $defaultdb : $distro->dbtype, // let distro skip dbtype selection
+ 'dbhost' => empty($distro->dbhost) ? 'localhost' : $distro->dbhost, // let distros set dbhost
'dbname' => 'moodle',
- 'dbuser' => 'root',
+ 'dbuser' => empty($distro->dbuser) ? 'root' : $distro->dbuser, // let distros set dbuser
'dbpass' => '',
'dbsocket' => false,
'prefix' => 'mdl_',
@@ -516,6 +526,9 @@
}
$CFG->dbpass = cli_input($prompt, $options['dbpass']);
+ if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation
+ $distro = distro_pre_create_db($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']), $distro);
+ }
$hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist'=>0, 'dbsocket'=>$options['dbsocket']));
} while ($hint_database !== '');

0 comments on commit b0bc0be

Please sign in to comment.
Something went wrong with that request. Please try again.