} if ($config->stage > INSTALL_SAVE) { $config->stage = INSTALL_SAVE; } if ($config->stage == INSTALL_SAVE) { $CFG->early_install_lang = false; $database = moodle_database::get_driver_instance($config->dbtype, 'native'); if (!$database->driver_installed()) { $config->stage = INSTALL_DATABASETYPE; } else { if (function_exists('distro_pre_create_db')) { // Hook for distros needing to do something before DB creation $distro = distro_pre_create_db($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbport'=>$config->dbport, 'dbsocket'=>$config->dbsocket), $distro); } $hint_database = install_db_validate($database, $config->dbhost, $config->dbuser, $config->dbpass, $config->dbname, $config->prefix, array('dbpersist'=>0, 'dbport'=>$config->dbport, 'dbsocket'=>$config->dbsocket)); if ($hint_database === '') { $configphp = install_generate_configphp($database, $CFG); umask(0137); if (($fh = @fopen($configfile, 'w')) !== false) { fwrite($fh, $configphp); fclose($fh); } if (file_exists($configfile)) { // config created, let's continue! redirect("$CFG->wwwroot/$config->admin/index.php?lang=$config->lang");
$CFG->dbuser = $options['dbuser']; } // ask for db password if ($interactive) { cli_separator(); cli_heading(get_string('databasepass', 'install')); do { if ($options['dbpass'] !== '') { $prompt = get_string('clitypevaluedefault', 'admin', $options['dbpass']); } else { $prompt = get_string('clitypevalue', 'admin'); } $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, 'dbport' => $CFG->dboptions['dbport'], 'dbsocket' => $CFG->dboptions['dbsocket']), $distro); } $hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist' => 0, 'dbport' => $CFG->dboptions['dbport'], 'dbsocket' => $CFG->dboptions['dbsocket'])); } while ($hint_database !== ''); } else { $CFG->dbpass = $options['dbpass']; $hint_database = install_db_validate($database, $CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname, $CFG->prefix, array('dbpersist' => 0, 'dbport' => $CFG->dboptions['dbport'], 'dbsocket' => $CFG->dboptions['dbsocket'])); if ($hint_database !== '') { cli_error(get_string('dbconnectionerror', 'install')); } } // ask for fullname if ($interactive) { cli_separator(); cli_heading(get_string('fullsitename', 'moodle')); if ($options['fullname'] !== '') {