fixes for finishing installation correctly

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-08-20 10:44:05 +02:00
parent 9dc95e086d
commit 2c9b2c1d67
7 changed files with 52 additions and 10 deletions

View File

@@ -29,7 +29,7 @@ return [
'title' => lng('admin.spfsettings'),
'icon' => 'fa-solid fa-clipboard-check',
'fields' => [
'spf_enabled' => [
'use_spf' => [
'label' => lng('spf.use_spf'),
'settinggroup' => 'spf',
'varname' => 'use_spf',

View File

@@ -51,10 +51,9 @@ if (!file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
}
// check installation status
// @fixme userdata.inc.php is created iun step3 so step4 is never shown
if (file_exists(dirname(__DIR__) . '/lib/userdata.inc.php')) {
http_response_code(404);
die();
header("Location: ../");
exit;
}
require dirname(__DIR__) . '/vendor/autoload.php';

View File

@@ -49,13 +49,22 @@ final class InstallCommand extends Command
$this->setName('froxlor:install');
$this->setDescription('Installation process to use instead of web-ui');
$this->addArgument('input-file', InputArgument::OPTIONAL, 'Optional JSON array file to use for unattended installations');
$this->addOption('print-example-file', 'p', InputOption::VALUE_NONE, 'Outputs an example JSON content to be used with the input file parameter');
$this->addOption('print-example-file', 'p', InputOption::VALUE_NONE, 'Outputs an example JSON content to be used with the input file parameter')
->addOption('create-userdata-from-str', 'c', InputOption::VALUE_REQUIRED, 'Creates lib/userdata.inc.php file from string created by web-install process');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$result = self::SUCCESS;
if ($input->getOption('create-userdata-from-str') !== false) {
$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;
}
session_start();
require __DIR__ . '/install.functions.php';

View File

@@ -404,8 +404,20 @@ class Install
$default = 'bullseye';
// read os-release
if (@file_exists('/etc/os-release')) {
$os_dist = parse_ini_file('/etc/os-release', false);
if (@file_exists('/etc/os-release') && is_readable('/etc/os-release')) {
if (function_exists('parse_ini_file')) {
$os_dist = parse_ini_file('/etc/os-release', false);
} else {
$osrf = explode("\n", file_get_contents('/etc/os-release'));
foreach ($osrf as $line) {
$osrfline = explode("\n", $line);
if ($osrfline[0] == 'VERSION_CODENAME') {
$os_dist['VERSION_CODENAME'] = $osrfline[1];
} else if ($osrfline[0] == 'ID') {
$os_dist['ID'] = $osrfline[1];
}
}
}
return strtolower($os_dist['VERSION_CODENAME'] ?? ($os_dist['ID'] ?? $default));
}
return $default;

View File

@@ -116,6 +116,7 @@ class Core
$this->doDataEntries($pdo);
// create JSON array for config-services
$this->createJsonArray();
$this->createUserdataParamStr();
}
public function getUnprivilegedPdo(): PDO
@@ -675,4 +676,23 @@ class Core
];
$_SESSION['installation']['json_params'] = json_encode($json_params);
}
private function createUserdataParamStr()
{
$req_fields = [
'mysql_host',
'mysql_unprivileged_user',
'mysql_unprivileged_pass',
'mysql_database',
'mysql_root_user',
'mysql_root_pass',
'mysql_ssl_ca_file',
'mysql_ssl_verify_server_certificate'
];
$json_params = [];
foreach ($req_fields as $field) {
$json_params[$field] = $this->validatedData[$field] ?? "";
}
$_SESSION['installation']['ud_str'] = base64_encode(json_encode($json_params));
}
}

View File

@@ -220,9 +220,11 @@ return [
'system' => [
'label' => lng('install.install.runcmd'),
'type' => 'textarea',
'value' => !empty($_SESSION['installation']['json_params']) ? Froxlor::getInstallDir() . "bin/froxlor-cli froxlor:config-services -a '" . $_SESSION['installation']['json_params'] . "' --yes-to-all" : "something went wrong...",
'value' => (!empty($_SESSION['installation']['ud_str']) ? Froxlor::getInstallDir() . "bin/froxlor-cli froxlor:install -c '" . $_SESSION['installation']['ud_str'] . "'" : "something went wrong...") . "\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' => 3
'rows' => 10,
'style' => 'min-height:16rem;'
],
'manual_config' => [
'label' => lng('install.install.manual_config'),

View File

@@ -201,7 +201,7 @@
{% endmacro %}
{% macro textarea(id, field) %}
<textarea {% if field.visible is defined and field.visible == false %} disabled {% endif %} rows="{{ field.rows|default('12') }}" cols="{{ field.cols|default('60') }}" id="{{ id }}" name="{{ id }}" class="form-control {% if field.valid is defined and field.valid == false %}is-invalid{% endif %}" {% if field.mandatory is defined and field.mandatory %} required {% endif %} {% if field.readonly is defined and field.readonly %} readonly {% endif %} {% if field.placeholder is defined %} placeholder="{{ field.placeholder }}" {% endif %}>{{ field.value }}</textarea>
<textarea {% if field.visible is defined and field.visible == false %} disabled {% endif %} rows="{{ field.rows|default('12') }}" cols="{{ field.cols|default('60') }}" id="{{ id }}" name="{{ id }}" class="form-control {% if field.valid is defined and field.valid == false %}is-invalid{% endif %}" {% if field.mandatory is defined and field.mandatory %} required {% endif %} {% if field.readonly is defined and field.readonly %} readonly {% endif %} {% if field.placeholder is defined %} placeholder="{{ field.placeholder }}" {% endif %} {% if field.style is defined %} style="{{ field.style }}" {% endif %}>{{ field.value }}</textarea>
{% endmacro %}
{% macro link(id, field) %}