Merge branch 'w25_MDL-26455_m26_installport' of git://github.com/skodak/moodle
Conflicts: admin/cli/install.php
This commit is contained in:
+36
-5
@@ -58,7 +58,8 @@ Options:
|
||||
--dbname=NAME Database name. Default is moodle
|
||||
--dbuser=USERNAME Database user. Default is root
|
||||
--dbpass=PASSWORD Database password. Default is blank
|
||||
--dbsocket Use database sockets. Available for some databases only.
|
||||
--dbport=NUMBER Use database port.
|
||||
--dbsocket=PATH Use database socket, 1 means default. Available for some databases only.
|
||||
--prefix=STRING Table prefix for above database tables. Default is mdl_
|
||||
--fullname=STRING The fullname of the site
|
||||
--shortname=STRING The shortname of the site
|
||||
@@ -151,6 +152,7 @@ $CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
$CFG->ostype = (stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin')) ? 'WINDOWS' : 'UNIX';
|
||||
$CFG->developerdebug = true;
|
||||
$CFG->dboptions = array();
|
||||
|
||||
$parts = explode('/', str_replace('\\', '/', dirname(dirname(__FILE__))));
|
||||
$CFG->admin = array_pop($parts);
|
||||
@@ -205,7 +207,8 @@ list($options, $unrecognized) = cli_get_params(
|
||||
'dbname' => 'moodle',
|
||||
'dbuser' => empty($distro->dbuser) ? 'root' : $distro->dbuser, // let distros set dbuser
|
||||
'dbpass' => '',
|
||||
'dbsocket' => false,
|
||||
'dbport' => '',
|
||||
'dbsocket' => '',
|
||||
'prefix' => 'mdl_',
|
||||
'fullname' => '',
|
||||
'shortname' => '',
|
||||
@@ -498,6 +501,34 @@ if ($interactive) {
|
||||
$CFG->prefix = $options['prefix'];
|
||||
}
|
||||
|
||||
// ask for db port
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databaseport', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbport']);
|
||||
$CFG->dboptions['dbport'] = (int)cli_input($prompt, $options['dbport']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbport'] = (int)$options['dbport'];
|
||||
}
|
||||
if ($CFG->dboptions['dbport'] <= 0) {
|
||||
$CFG->dboptions['dbport'] = '';
|
||||
}
|
||||
|
||||
// ask for db socket
|
||||
if ($CFG->ostype === 'WINDOWS') {
|
||||
$CFG->dboptions['dbsocket'] = '';
|
||||
|
||||
} else if ($interactive and empty($CFG->dboptions['dbport'])) {
|
||||
cli_separator();
|
||||
cli_heading(get_string('databasesocket', 'install'));
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', $options['dbsocket']);
|
||||
$CFG->dboptions['dbsocket'] = cli_input($prompt, $options['dbsocket']);
|
||||
|
||||
} else {
|
||||
$CFG->dboptions['dbsocket'] = $options['dbsocket'];
|
||||
}
|
||||
|
||||
// ask for db user
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
@@ -526,14 +557,14 @@ if ($interactive) {
|
||||
|
||||
$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);
|
||||
$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, 'dbsocket'=>$options['dbsocket']));
|
||||
$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, 'dbsocket'=>$options['dbsocket']));
|
||||
$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'));
|
||||
}
|
||||
|
||||
+16
-7
@@ -129,7 +129,12 @@ if (!empty($_POST)) {
|
||||
$config->dbpass = trim($_POST['dbpass']);
|
||||
$config->dbname = trim($_POST['dbname']);
|
||||
$config->prefix = trim($_POST['prefix']);
|
||||
$config->dbsocket = (int)(!empty($_POST['dbsocket']));
|
||||
$config->dbport = (int)trim($_POST['dbport']);
|
||||
$config->dbsocket = trim($_POST['dbsocket']);
|
||||
|
||||
if ($config->dbport <= 0) {
|
||||
$config->dbport = '';
|
||||
}
|
||||
|
||||
$config->admin = empty($_POST['admin']) ? 'admin' : trim($_POST['admin']);
|
||||
|
||||
@@ -144,7 +149,8 @@ if (!empty($_POST)) {
|
||||
$config->dbpass = '';
|
||||
$config->dbname = 'moodle';
|
||||
$config->prefix = 'mdl_';
|
||||
$config->dbsocket = 0;
|
||||
$config->dbport = empty($distro->dbport) ? '' : $distro->dbport;
|
||||
$config->dbsocket = empty($distro->dbsocket) ? '' : $distro->dbsocket;
|
||||
|
||||
$config->admin = 'admin';
|
||||
|
||||
@@ -264,9 +270,9 @@ if ($config->stage == INSTALL_SAVE) {
|
||||
$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, 'dbsocket'=>$config->dbsocket), $distro);
|
||||
$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, 'dbsocket'=>$config->dbsocket));
|
||||
$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);
|
||||
@@ -406,6 +412,7 @@ if ($config->stage == INSTALL_DATABASE) {
|
||||
$strdbuser = get_string('databaseuser', 'install');
|
||||
$strdbpass = get_string('databasepass', 'install');
|
||||
$strprefix = get_string('dbprefix', 'install');
|
||||
$strdbport = get_string('databaseport', 'install');
|
||||
$strdbsocket = get_string('databasesocket', 'install');
|
||||
|
||||
echo '<div class="userinput">';
|
||||
@@ -433,11 +440,13 @@ if ($config->stage == INSTALL_DATABASE) {
|
||||
echo '<input id="id_prefix" name="prefix" type="text" value="'.s($config->prefix).'" size="10" class="forminput" />';
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="formrow"><label for="id_prefix" class="formlabel">'.$strdbport.'</label>';
|
||||
echo '<input id="id_dbport" name="dbport" type="text" value="'.s($config->dbport).'" size="10" class="forminput" />';
|
||||
echo '</div>';
|
||||
|
||||
if (!(stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin'))) {
|
||||
$checked = $config->dbsocket ? 'checked="checked' : '';
|
||||
echo '<div class="formrow"><label for="id_dbsocket" class="formlabel">'.$strdbsocket.'</label>';
|
||||
echo '<input type="hidden" value="0" name="dbsocket" />';
|
||||
echo '<input type="checkbox" id="id_dbsocket" value="1" name="dbsocket" '.$checked.' class="forminput" />';
|
||||
echo '<input id="id_dbsocket" name="dbsocket" type="text" value="'.s($config->dbsocket).'" size="50" class="forminput" />';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -86,6 +86,7 @@ $string['databasehead'] = 'Database settings';
|
||||
$string['databasehost'] = 'Database host';
|
||||
$string['databasename'] = 'Database name';
|
||||
$string['databasepass'] = 'Database password';
|
||||
$string['databaseport'] = 'Database port';
|
||||
$string['databasesettings'] = 'Now you need to configure the database where most Moodle data
|
||||
will be stored. This database must already have been created
|
||||
and a username and password created to access it.<br />
|
||||
|
||||
Reference in New Issue
Block a user