diff --git a/admin/cli/install.php b/admin/cli/install.php index 4e934a275db..04d1ee891cb 100644 --- a/admin/cli/install.php +++ b/admin/cli/install.php @@ -133,9 +133,6 @@ $CFG->dirroot = dirname(dirname(dirname(__FILE__))); $CFG->libdir = "$CFG->dirroot/lib"; $CFG->wwwroot = "http://localhost"; $CFG->httpswwwroot = $CFG->wwwroot; -$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'); -$CFG->tempdir = $CFG->dataroot.'/temp'; -$CFG->cachedir = $CFG->dataroot.'/temp'; $CFG->docroot = 'http://docs.moodle.org'; $CFG->running_installer = true; $CFG->early_install_lang = true; @@ -186,7 +183,7 @@ list($options, $unrecognized) = cli_get_params( 'chmod' => '2777', 'lang' => $CFG->lang, 'wwwroot' => '', - 'dataroot' => $CFG->dataroot, + 'dataroot' => str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata'), 'dbtype' => $defaultdb, 'dbhost' => 'localhost', 'dbname' => 'moodle', @@ -330,9 +327,12 @@ $CFG->httpswwwroot = $CFG->wwwroot; //We need dataroot before lang download -if (!empty($options['dataroot'])) { - $CFG->dataroot = $options['dataroot']; +$dataroot = clean_param($options['dataroot'], PARAM_PATH); +if ($dataroot !== $options['dataroot']) { + $a = (object)array('option' => 'dataroot', 'value' => $options['dataroot']); + cli_error(get_string('cliincorrectvalueerror', 'admin', $a)); } +$CFG->dataroot = $dataroot; if ($interactive) { cli_separator(); $i=0; @@ -380,6 +380,8 @@ if ($interactive) { cli_error(get_string('pathserrcreatedataroot', 'install', $a)); } } +$CFG->tempdir = $CFG->dataroot.'/temp'; +$CFG->cachedir = $CFG->dataroot.'/cache'; // download required lang packs if ($CFG->lang !== 'en') { diff --git a/install.php b/install.php index 533c7aebd02..341a1472d27 100644 --- a/install.php +++ b/install.php @@ -166,7 +166,7 @@ $CFG->wwwroot = install_guess_wwwroot(); // can not be changed - pp $CFG->httpswwwroot = $CFG->wwwroot; $CFG->dataroot = $config->dataroot; $CFG->tempdir = $CFG->dataroot.'/temp'; -$CFG->cachedir = $CFG->dataroot.'/temp'; +$CFG->cachedir = $CFG->dataroot.'/cache'; $CFG->admin = $config->admin; $CFG->docroot = 'http://docs.moodle.org'; $CFG->langotherroot = $CFG->dataroot.'/lang'; diff --git a/lib/installlib.php b/lib/installlib.php index c6cb423c187..566bc8cb3c6 100644 --- a/lib/installlib.php +++ b/lib/installlib.php @@ -106,7 +106,27 @@ function install_init_dataroot($dataroot, $dirpermissions) { return false; // we can not continue } - // now create the lang folder - we need it and it makes sure we can really write in dataroot + // create the directory for $CFG->tempdir + if (!is_dir("$dataroot/temp")) { + if (!mkdir("$dataroot/temp", $dirpermissions, true)) { + return false; + } + } + if (!is_writable("$dataroot/temp")) { + return false; // we can not continue + } + + // create the directory for $CFG->cachedir + if (!is_dir("$dataroot/cache")) { + if (!mkdir("$dataroot/cache", $dirpermissions, true)) { + return false; + } + } + if (!is_writable("$dataroot/cache")) { + return false; // we can not continue + } + + // create the directory for $CFG->langotherroot if (!is_dir("$dataroot/lang")) { if (!mkdir("$dataroot/lang", $dirpermissions, true)) { return false;