summaryrefslogtreecommitdiffstats
path: root/core/command/maintenance
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-03-10 23:44:29 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2015-03-11 09:27:12 +0100
commit6c1a1234f8c5a064a72cb23cd397edcb9c6f0577 (patch)
tree531cc7f3dd6b70f6604f719828f7ba98c37dda63 /core/command/maintenance
parent81fa9550a0e136421c1dacad3d26fdb19e9c63a3 (diff)
downloadnextcloud-server-6c1a1234f8c5a064a72cb23cd397edcb9c6f0577.tar.gz
nextcloud-server-6c1a1234f8c5a064a72cb23cd397edcb9c6f0577.zip
Properly handle available databases at runtime and respect setup checks in command line as well
Diffstat (limited to 'core/command/maintenance')
-rw-r--r--core/command/maintenance/install.php59
1 files changed, 36 insertions, 23 deletions
diff --git a/core/command/maintenance/install.php b/core/command/maintenance/install.php
index 0b01afc20ed..e92a546daac 100644
--- a/core/command/maintenance/install.php
+++ b/core/command/maintenance/install.php
@@ -3,6 +3,7 @@
namespace OC\Core\Command\Maintenance;
use InvalidArgumentException;
+use OC\Setup;
use OCP\IConfig;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
@@ -38,39 +39,36 @@ class Install extends Command {
protected function execute(InputInterface $input, OutputInterface $output) {
- $options = $this->validateInput($input, $output);
-
- $errors = \OC\Setup::install($options);
- if (count($errors) === 0) {
- $output->writeln("ownCloud was successfully installed");
- return 0;
- }
- foreach($errors as $error) {
- if (is_array($error)) {
- $output->writeln('<error>' . (string)$error['error'] . '</error>');
- $output->writeln('<info> -> ' . (string)$error['hint'] . '</info>');
- } else {
- $output->writeln('<error>' . (string)$error . '</error>');
- }
+ // validate the environment
+ $setupHelper = new Setup($this->config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'), new \OC_Defaults());
+ $sysInfo = $setupHelper->getSystemInfo();
+ $errors = $sysInfo['errors'];
+ if (count($errors) > 0) {
+ $this->printErrors($output, $errors);
+ return 1;
}
- return 1;
+ // validate user input
+ $options = $this->validateInput($input, $output, array_keys($sysInfo['databases']));
+
+ // perform installation
+ $errors = $setupHelper->install($options);
+ if (count($errors) > 0) {
+ $this->printErrors($output, $errors);
+ return 1;
+ }
+ $output->writeln("ownCloud was successfully installed");
+ return 0;
}
/**
* @param InputInterface $input
* @param OutputInterface $output
+ * @param string[] $supportedDatabases
* @return array
*/
- protected function validateInput(InputInterface $input, OutputInterface $output) {
+ protected function validateInput(InputInterface $input, OutputInterface $output, $supportedDatabases) {
$db = strtolower($input->getOption('database'));
- $supportedDatabases = $this->config->getSystemValue('supportedDatabases', [
- 'sqlite',
- 'mysql',
- 'pgsql',
- 'oci',
- 'mssql'
- ]);
if (!in_array($db, $supportedDatabases)) {
throw new InvalidArgumentException("Database <$db> is not supported.");
@@ -126,4 +124,19 @@ class Install extends Command {
];
return $options;
}
+
+ /**
+ * @param OutputInterface $output
+ * @param $errors
+ */
+ protected function printErrors(OutputInterface $output, $errors) {
+ foreach ($errors as $error) {
+ if (is_array($error)) {
+ $output->writeln('<error>' . (string)$error['error'] . '</error>');
+ $output->writeln('<info> -> ' . (string)$error['hint'] . '</info>');
+ } else {
+ $output->writeln('<error>' . (string)$error . '</error>');
+ }
+ }
+ }
}