MDL-22294 CLI installer now supports --dataroot argument correctly

This commit is contained in:
David Mudrak 2010-05-10 15:59:21 +00:00
parent 7d73574c6f
commit 59ba2bb002
3 changed files with 13 additions and 10 deletions

View File

@ -47,8 +47,8 @@ Options:
--wwwroot=URL Web address for the Moodle site,
required in non-interactive mode.
--dataroot=DIR Location of the moodle data folder,
must not be web accessible. Default is moodleroot
in parent directory.
must not be web accessible. Default is moodledata
in the parent directory.
--dbtype=TYPE Database type. Default is mysqli
--dbhost=HOST Database host. Default is localhost
--dbname=NAME Database name. Default is moodle
@ -110,8 +110,10 @@ $CFG->dirroot = str_replace('\\', '/', dirname(dirname(dirname(__FI
$CFG->libdir = "$CFG->dirroot/lib";
$CFG->wwwroot = "http://localhost";
$CFG->httpswwwroot = $CFG->wwwroot;
$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(__FILE__))).'/moodledata');
$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata');
$CFG->docroot = 'http://docs.moodle.org';
$CFG->langotherroot = $CFG->dataroot.'/lang';
$CFG->langlocalroot = $CFG->dataroot.'/lang';
$CFG->directorypermissions = 00777;
$CFG->running_installer = true;
$CFG->early_install_lang = true;
@ -293,20 +295,21 @@ if ($interactive) {
if (make_upload_directory('lang', false)) {
$error = '';
} else {
$error = get_string('pathserrcreatedataroot', 'install', $CFG->dataroot)."\n";
$a = (object)array('dataroot' => $CFG->dataroot);
$error = get_string('pathserrcreatedataroot', 'install', $a)."\n";
}
}
} while ($error !== '');
} else {
$CFG->dataroot = $options['dataroot'];
if (is_dataroot_insecure()) {
$a = (object)array('option'=>'dataroot', 'value'=>$CFG->dataroot);
//TODO: use unsecure warning instead
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
cli_error(get_string('pathsunsecuredataroot', 'install'));
}
if (!make_upload_directory('lang', false)) {
cli_error(get_string('pathserrcreatedataroot', 'install', $CFG->dataroot));
$a = (object)array('dataroot' => $CFG->dataroot);
cli_error(get_string('pathserrcreatedataroot', 'install', $a));
}
}

View File

@ -134,7 +134,7 @@ function install_db_validate($database, $dbhost, $dbuser, $dbpass, $dbname, $pre
* @return string
*/
function install_generate_configphp($database, $cfg, $userealpath=false) {
$configphp = '<?php // Moodle Configuration File ' . PHP_EOL . PHP_EOL;
$configphp = '<?php // Moodle configuration file' . PHP_EOL . PHP_EOL;
$configphp .= 'unset($CFG);' . PHP_EOL;
$configphp .= '$CFG = new stdClass();' . PHP_EOL . PHP_EOL; // prevent PHP5 strict warnings

View File

@ -785,7 +785,7 @@ function make_upload_directory($directory, $shownotices=true) {
umask(0000);
if (!file_exists($currdir)) {
if (!mkdir($currdir, $CFG->directorypermissions) or !is_writable($currdir)) {
if (!mkdir($currdir, $CFG->directorypermissions, true) or !is_writable($currdir)) {
if ($shownotices) {
echo '<div class="notifyproblem" align="center">ERROR: You need to create the directory '.
$currdir .' with web server write access</div>'."<br />\n";