Add --admin-email to cli installer
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
This commit is contained in:
parent
6b730b4c47
commit
6c805ec9ba
|
@ -67,6 +67,7 @@ class Install extends Command {
|
||||||
->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null)
|
->addOption('database-table-space', null, InputOption::VALUE_OPTIONAL, 'Table space of the database (oci only)', null)
|
||||||
->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'User name of the admin account', 'admin')
|
->addOption('admin-user', null, InputOption::VALUE_REQUIRED, 'User name of the admin account', 'admin')
|
||||||
->addOption('admin-pass', null, InputOption::VALUE_REQUIRED, 'Password of the admin account')
|
->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");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +142,7 @@ class Install extends Command {
|
||||||
}
|
}
|
||||||
$adminLogin = $input->getOption('admin-user');
|
$adminLogin = $input->getOption('admin-user');
|
||||||
$adminPassword = $input->getOption('admin-pass');
|
$adminPassword = $input->getOption('admin-pass');
|
||||||
|
$adminEmail = $input->getOption('admin-email');
|
||||||
$dataDir = $input->getOption('data-dir');
|
$dataDir = $input->getOption('data-dir');
|
||||||
|
|
||||||
if ($db !== 'sqlite') {
|
if ($db !== 'sqlite') {
|
||||||
|
@ -179,6 +181,7 @@ class Install extends Command {
|
||||||
'dbtableprefix' => $dbTablePrefix,
|
'dbtableprefix' => $dbTablePrefix,
|
||||||
'adminlogin' => $adminLogin,
|
'adminlogin' => $adminLogin,
|
||||||
'adminpass' => $adminPassword,
|
'adminpass' => $adminPassword,
|
||||||
|
'adminemail' => $adminEmail,
|
||||||
'directory' => $dataDir
|
'directory' => $dataDir
|
||||||
];
|
];
|
||||||
if ($db === 'oci') {
|
if ($db === 'oci') {
|
||||||
|
|
|
@ -52,6 +52,7 @@ use OC\Preview\BackgroundCleanupJob;
|
||||||
use OCP\Defaults;
|
use OCP\Defaults;
|
||||||
use OCP\IL10N;
|
use OCP\IL10N;
|
||||||
use OCP\ILogger;
|
use OCP\ILogger;
|
||||||
|
use OCP\IUser;
|
||||||
use OCP\Security\ISecureRandom;
|
use OCP\Security\ISecureRandom;
|
||||||
|
|
||||||
class Setup {
|
class Setup {
|
||||||
|
@ -368,6 +369,14 @@ class Setup {
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$error[] = "User <$username> could not be created.";
|
$error[] = "User <$username> could not be created.";
|
||||||
}
|
}
|
||||||
|
if ($user instanceof IUser && !empty($options['adminemail'])) {
|
||||||
|
$adminEmail = htmlspecialchars_decode($options['adminemail']);
|
||||||
|
if (filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$user->setEMailAddress($adminEmail);
|
||||||
|
} else {
|
||||||
|
$error[] = "Invalid e-mail-address <$adminEmail> for <$username>.";
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch(Exception $exception) {
|
} catch(Exception $exception) {
|
||||||
$error[] = $exception->getMessage();
|
$error[] = $exception->getMessage();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue