From 07094f231ac0631c9c7ec2e21932567b190a66e2 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sat, 20 Aug 2022 11:21:49 +0200 Subject: [PATCH] minor fixes in installation process Signed-off-by: Michael Kaufmann --- lib/Froxlor/Cli/InstallCommand.php | 17 +++++++++++------ lib/Froxlor/Install/Install/Core.php | 6 ++++-- lib/formfields/install/formfield.install.php | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/lib/Froxlor/Cli/InstallCommand.php b/lib/Froxlor/Cli/InstallCommand.php index bfcc7721..03e1a107 100644 --- a/lib/Froxlor/Cli/InstallCommand.php +++ b/lib/Froxlor/Cli/InstallCommand.php @@ -57,12 +57,16 @@ final class InstallCommand extends Command { $result = self::SUCCESS; - if ($input->getOption('create-userdata-from-str') !== false) { + if ($input->getOption('create-userdata-from-str') !== null) { $ud_str = $input->getOption('create-userdata-from-str'); - $ud_dec = json_decode(base64_decode($ud_str), true); - $core = new Core($ud_dec); - $core->createUserdataConf(); - return $result; + $ud_dec = @json_decode(@base64_decode($ud_str), true); + if (is_array($ud_dec) && !empty($ud_dec) && count($ud_dec) == 8) { + $core = new Core($ud_dec); + $core->createUserdataConf(); + return $result; + } + $output->writeln("Invalid parameter value."); + return self::INVALID; } session_start(); @@ -130,6 +134,7 @@ final class InstallCommand extends Command $this->io->info('Running unattended installation'); } else { $extended = $this->io->confirm('Use advanced installation mode?', false); + $decoded_input = []; } $result = $this->showStep(0, $extended, $decoded_input); @@ -246,7 +251,7 @@ final class InstallCommand extends Command if ($step == 3) { // do actual install with data from $this->formfielddata $core = new Core($this->formfielddata); - $core->doInstall(); + $core->doInstall(false); $core->createUserdataConf(); } return $this->showStep(++$step, $extended, $decoded_input); diff --git a/lib/Froxlor/Install/Install/Core.php b/lib/Froxlor/Install/Install/Core.php index 9ae7099a..e9ed07b3 100644 --- a/lib/Froxlor/Install/Install/Core.php +++ b/lib/Froxlor/Install/Install/Core.php @@ -52,7 +52,7 @@ class Core * @return void * @throws Exception */ - public function doInstall() + public function doInstall(bool $create_ud_str = true) { $options = [ 'PDO::MYSQL_ATTR_INIT_COMMAND' => 'SET names utf8' @@ -116,7 +116,9 @@ class Core $this->doDataEntries($pdo); // create JSON array for config-services $this->createJsonArray(); - $this->createUserdataParamStr(); + if ($create_ud_str) { + $this->createUserdataParamStr(); + } } public function getUnprivilegedPdo(): PDO diff --git a/lib/formfields/install/formfield.install.php b/lib/formfields/install/formfield.install.php index 1d5d7f04..4b34b939 100644 --- a/lib/formfields/install/formfield.install.php +++ b/lib/formfields/install/formfield.install.php @@ -220,7 +220,7 @@ return [ 'system' => [ 'label' => lng('install.install.runcmd'), 'type' => 'textarea', - 'value' => (!empty($_SESSION['installation']['ud_str']) ? Froxlor::getInstallDir() . "bin/froxlor-cli froxlor:install -c '" . $_SESSION['installation']['ud_str'] . "'" : "something went wrong...") . "\n" . + 'value' => (!empty($_SESSION['installation']['ud_str']) ? Froxlor::getInstallDir() . "bin/froxlor-cli froxlor:install -c '" . $_SESSION['installation']['ud_str'] . "'\n" : "") . (!empty($_SESSION['installation']['json_params']) ? Froxlor::getInstallDir() . "bin/froxlor-cli froxlor:config-services -a '" . $_SESSION['installation']['json_params'] . "' --yes-to-all" : "something went wrong..."), 'readonly' => true, 'rows' => 10,