cli/setup: Issue nice error messages when creating the config directory fails

This commit is contained in:
Eric Lippmann 2014-12-30 16:03:05 +01:00
parent 865b5c126a
commit 9f545535a0

View File

@ -55,22 +55,31 @@ class ConfigCommand extends Command
)); ));
} }
if (! mkdir($configDir)) { if (! file_exists($configDir) && ! @mkdir($configDir)) {
$this->fail(sprintf($this->translate('Can\'t create configuration directory %s'), $configDir)); $e = error_get_last();
}
if (! chmod($configDir, octdec($mode))) {
$this->fail(sprintf( $this->fail(sprintf(
$this->translate('Can\'t change the mode of the configuration directory to %s'), $this->translate('Can\'t create configuration directory %s: %s'),
$mode $configDir,
$e['message']
)); ));
} }
if (! chgrp($configDir, $group)) { if (! @chmod($configDir, octdec($mode))) {
$e = error_get_last();
$this->fail(sprintf( $this->fail(sprintf(
$this->translate('Can\'t change the to change the group of %s to %s'), $this->translate('Can\'t change the mode of the configuration directory to %s: %s'),
$mode,
$e['message']
));
}
if (! @chgrp($configDir, $group)) {
$e = error_get_last();
$this->fail(sprintf(
$this->translate('Can\'t change the group of %s to %s: %s'),
$configDir, $configDir,
$group $group,
$e['message']
)); ));
} }