mirror of
https://github.com/moodle/moodle.git
synced 2025-04-22 00:42:54 +02:00
MDL-22295 CLI installer supports --chmod argument to define $CFG->directorypermissions
This commit is contained in:
parent
7a4b8aebb0
commit
7be6768138
@ -43,6 +43,9 @@ or use chmod/chown after installation.
|
||||
Site defaults may be changed via local/defaults.php.
|
||||
|
||||
Options:
|
||||
--chmod=OCTAL-MODE Permissions of new directories created within dataroot.
|
||||
Default is 2777. You may want to change it to 2770
|
||||
or 2750 or 750. See chmod man page for details.
|
||||
--lang=CODE Installation and default site language.
|
||||
--wwwroot=URL Web address for the Moodle site,
|
||||
required in non-interactive mode.
|
||||
@ -113,7 +116,6 @@ $CFG->wwwroot = "http://localhost";
|
||||
$CFG->httpswwwroot = $CFG->wwwroot;
|
||||
$CFG->dataroot = str_replace('\\', '/', dirname(dirname(dirname(dirname(__FILE__)))).'/moodledata');
|
||||
$CFG->docroot = 'http://docs.moodle.org';
|
||||
$CFG->directorypermissions = 00777;
|
||||
$CFG->running_installer = true;
|
||||
$CFG->early_install_lang = true;
|
||||
|
||||
@ -164,6 +166,7 @@ if (empty($databases)) {
|
||||
// now get cli options
|
||||
list($options, $unrecognized) = cli_get_params(
|
||||
array(
|
||||
'chmod' => '02777',
|
||||
'lang' => $CFG->lang,
|
||||
'wwwroot' => '',
|
||||
'dataroot' => $CFG->dataroot,
|
||||
@ -243,6 +246,32 @@ if ($interactive) {
|
||||
// already selected and verified
|
||||
}
|
||||
|
||||
// Set directorypermissions first
|
||||
$chmod = octdec(clean_param($options['chmod'], PARAM_INT));
|
||||
if ($interactive) {
|
||||
cli_separator();
|
||||
cli_heading('Data directories permission'); // todo localize
|
||||
$prompt = get_string('clitypevaluedefault', 'admin', decoct($chmod));
|
||||
$error = '';
|
||||
do {
|
||||
echo $error;
|
||||
$input = cli_input($prompt, $chmod);
|
||||
$input = octdec(clean_param($input, PARAM_INT));
|
||||
if (empty($input)) {
|
||||
$error = get_string('cliincorrectvalueretry', 'admin')."\n";
|
||||
} else {
|
||||
$error = '';
|
||||
}
|
||||
} while ($error !== '');
|
||||
$chmod = $input;
|
||||
|
||||
} else {
|
||||
if (empty($chmod)) {
|
||||
$a = (object)array('option' => 'chmod', 'value' => decoct($chmod));
|
||||
cli_error(get_string('cliincorrectvalueerror', 'admin', $a));
|
||||
}
|
||||
}
|
||||
$CFG->directorypermissions = $chmod;
|
||||
|
||||
//We need wwwroot before we test dataroot
|
||||
$wwwroot = clean_param($options['wwwroot'], PARAM_URL);
|
||||
|
@ -165,7 +165,12 @@ function install_generate_configphp($database, $cfg, $userealpath=false) {
|
||||
|
||||
$configphp .= '$CFG->admin = '.var_export($cfg->admin, true) . ';' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$configphp .= '$CFG->directorypermissions = 00777; // try 02777 on a server in Safe Mode' . PHP_EOL . PHP_EOL;
|
||||
if (empty($cfg->directorypermissions)) {
|
||||
$chmod = '02777';
|
||||
} else {
|
||||
$chmod = '0' . decoct($cfg->directorypermissions);
|
||||
}
|
||||
$configphp .= '$CFG->directorypermissions = ' . $chmod . ';' . PHP_EOL . PHP_EOL;
|
||||
|
||||
$configphp .= '$CFG->passwordsaltmain = '.var_export(complex_random_string(), true) . ';' . PHP_EOL . PHP_EOL;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user