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, --wwwroot=URL Web address for the Moodle site,
required in non-interactive mode. required in non-interactive mode.
--dataroot=DIR Location of the moodle data folder, --dataroot=DIR Location of the moodle data folder,
must not be web accessible. Default is moodleroot must not be web accessible. Default is moodledata
in parent directory. in the parent directory.
--dbtype=TYPE Database type. Default is mysqli --dbtype=TYPE Database type. Default is mysqli
--dbhost=HOST Database host. Default is localhost --dbhost=HOST Database host. Default is localhost
--dbname=NAME Database name. Default is moodle --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->libdir = "$CFG->dirroot/lib";
$CFG->wwwroot = "http://localhost"; $CFG->wwwroot = "http://localhost";
$CFG->httpswwwroot = $CFG->wwwroot; $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->docroot = 'http://docs.moodle.org';
$CFG->langotherroot = $CFG->dataroot.'/lang';
$CFG->langlocalroot = $CFG->dataroot.'/lang';
$CFG->directorypermissions = 00777; $CFG->directorypermissions = 00777;
$CFG->running_installer = true; $CFG->running_installer = true;
$CFG->early_install_lang = true; $CFG->early_install_lang = true;
@ -293,20 +295,21 @@ if ($interactive) {
if (make_upload_directory('lang', false)) { if (make_upload_directory('lang', false)) {
$error = ''; $error = '';
} else { } else {
$error = get_string('pathserrcreatedataroot', 'install', $CFG->dataroot)."\n"; $a = (object)array('dataroot' => $CFG->dataroot);
$error = get_string('pathserrcreatedataroot', 'install', $a)."\n";
} }
} }
} while ($error !== ''); } while ($error !== '');
} else { } else {
$CFG->dataroot = $options['dataroot'];
if (is_dataroot_insecure()) { if (is_dataroot_insecure()) {
$a = (object)array('option'=>'dataroot', 'value'=>$CFG->dataroot); cli_error(get_string('pathsunsecuredataroot', 'install'));
//TODO: use unsecure warning instead
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
} }
if (!make_upload_directory('lang', false)) { 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 * @return string
*/ */
function install_generate_configphp($database, $cfg, $userealpath=false) { 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 .= 'unset($CFG);' . PHP_EOL;
$configphp .= '$CFG = new stdClass();' . PHP_EOL . PHP_EOL; // prevent PHP5 strict warnings $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); umask(0000);
if (!file_exists($currdir)) { 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) { if ($shownotices) {
echo '<div class="notifyproblem" align="center">ERROR: You need to create the directory '. echo '<div class="notifyproblem" align="center">ERROR: You need to create the directory '.
$currdir .' with web server write access</div>'."<br />\n"; $currdir .' with web server write access</div>'."<br />\n";