aboutsummaryrefslogtreecommitdiffstats
path: root/core/Command/Maintenance/Install.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/Command/Maintenance/Install.php')
-rw-r--r--core/Command/Maintenance/Install.php30
1 files changed, 17 insertions, 13 deletions
diff --git a/core/Command/Maintenance/Install.php b/core/Command/Maintenance/Install.php
index bfe955f9979..6170c5a2638 100644
--- a/core/Command/Maintenance/Install.php
+++ b/core/Command/Maintenance/Install.php
@@ -15,6 +15,7 @@ use OC\Console\TimestampFormatter;
use OC\Migration\ConsoleOutput;
use OC\Setup;
use OC\SystemConfig;
+use OCP\Server;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
@@ -43,23 +44,24 @@ class Install extends Command {
->addOption('database-user', null, InputOption::VALUE_REQUIRED, 'Login to connect to the database')
->addOption('database-pass', null, InputOption::VALUE_OPTIONAL, 'Password of the database user', null)
->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null)
+ ->addOption('disable-admin-user', null, InputOption::VALUE_NONE, 'Disable the creation of an admin user')
->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'Login of the admin account', 'admin')
->addOption('admin-pass', null, InputOption::VALUE_REQUIRED, 'Password of the admin account')
->addOption('admin-email', null, InputOption::VALUE_OPTIONAL, 'E-Mail of the admin account')
- ->addOption('data-dir', null, InputOption::VALUE_REQUIRED, 'Path to data directory', \OC::$SERVERROOT."/data");
+ ->addOption('data-dir', null, InputOption::VALUE_REQUIRED, 'Path to data directory', \OC::$SERVERROOT . '/data');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
// validate the environment
- $setupHelper = \OCP\Server::get(\OC\Setup::class);
+ $setupHelper = Server::get(Setup::class);
$sysInfo = $setupHelper->getSystemInfo(true);
$errors = $sysInfo['errors'];
if (count($errors) > 0) {
$this->printErrors($output, $errors);
// ignore the OS X setup warning
- if (count($errors) !== 1 ||
- (string)$errors[0]['error'] !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk! ') {
+ if (count($errors) !== 1
+ || (string)$errors[0]['error'] !== 'Mac OS X is not supported and Nextcloud will not work properly on this platform. Use it at your own risk!') {
return 1;
}
}
@@ -85,7 +87,7 @@ class Install extends Command {
if ($setupHelper->shouldRemoveCanInstallFile()) {
$output->writeln('<warn>Could not remove CAN_INSTALL from the config folder. Please remove this file manually.</warn>');
}
- $output->writeln("Nextcloud was successfully installed");
+ $output->writeln('Nextcloud was successfully installed');
return 0;
}
@@ -99,7 +101,7 @@ class Install extends Command {
$db = strtolower($input->getOption('database'));
if (!in_array($db, $supportedDatabases)) {
- throw new InvalidArgumentException("Database <$db> is not supported. " . implode(", ", $supportedDatabases) . " are supported.");
+ throw new InvalidArgumentException("Database <$db> is not supported. " . implode(', ', $supportedDatabases) . ' are supported.');
}
$dbUser = $input->getOption('database-user');
@@ -117,8 +119,9 @@ class Install extends Command {
$dbHost .= ':' . $dbPort;
}
if ($input->hasParameterOption('--database-pass')) {
- $dbPass = (string) $input->getOption('database-pass');
+ $dbPass = (string)$input->getOption('database-pass');
}
+ $disableAdminUser = (bool)$input->getOption('disable-admin-user');
$adminLogin = $input->getOption('admin-user');
$adminPassword = $input->getOption('admin-pass');
$adminEmail = $input->getOption('admin-email');
@@ -126,31 +129,31 @@ class Install extends Command {
if ($db !== 'sqlite') {
if (is_null($dbUser)) {
- throw new InvalidArgumentException("Database account not provided.");
+ throw new InvalidArgumentException('Database account not provided.');
}
if (is_null($dbName)) {
- throw new InvalidArgumentException("Database name not provided.");
+ throw new InvalidArgumentException('Database name not provided.');
}
if (is_null($dbPass)) {
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
- $question = new Question('What is the password to access the database with user <'.$dbUser.'>?');
+ $question = new Question('What is the password to access the database with user <' . $dbUser . '>?');
$question->setHidden(true);
$question->setHiddenFallback(false);
$dbPass = $helper->ask($input, $output, $question);
}
}
- if (is_null($adminPassword)) {
+ if (!$disableAdminUser && $adminPassword === null) {
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
- $question = new Question('What is the password you like to use for the admin account <'.$adminLogin.'>?');
+ $question = new Question('What is the password you like to use for the admin account <' . $adminLogin . '>?');
$question->setHidden(true);
$question->setHiddenFallback(false);
$adminPassword = $helper->ask($input, $output, $question);
}
- if ($adminEmail !== null && !filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
+ if (!$disableAdminUser && $adminEmail !== null && !filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException('Invalid e-mail-address <' . $adminEmail . '> for <' . $adminLogin . '>.');
}
@@ -160,6 +163,7 @@ class Install extends Command {
'dbpass' => $dbPass,
'dbname' => $dbName,
'dbhost' => $dbHost,
+ 'admindisable' => $disableAdminUser,
'adminlogin' => $adminLogin,
'adminpass' => $adminPassword,
'adminemail' => $adminEmail,