fixes for finishing installation correctly
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -29,7 +29,7 @@ return [
|
|||||||
'title' => lng('admin.spfsettings'),
|
'title' => lng('admin.spfsettings'),
|
||||||
'icon' => 'fa-solid fa-clipboard-check',
|
'icon' => 'fa-solid fa-clipboard-check',
|
||||||
'fields' => [
|
'fields' => [
|
||||||
'spf_enabled' => [
|
'use_spf' => [
|
||||||
'label' => lng('spf.use_spf'),
|
'label' => lng('spf.use_spf'),
|
||||||
'settinggroup' => 'spf',
|
'settinggroup' => 'spf',
|
||||||
'varname' => 'use_spf',
|
'varname' => 'use_spf',
|
||||||
|
|||||||
@@ -51,10 +51,9 @@ if (!file_exists(dirname(__DIR__) . '/vendor/autoload.php')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check installation status
|
// 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')) {
|
if (file_exists(dirname(__DIR__) . '/lib/userdata.inc.php')) {
|
||||||
http_response_code(404);
|
header("Location: ../");
|
||||||
die();
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
require dirname(__DIR__) . '/vendor/autoload.php';
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
||||||
|
|||||||
@@ -49,13 +49,22 @@ final class InstallCommand extends Command
|
|||||||
$this->setName('froxlor:install');
|
$this->setName('froxlor:install');
|
||||||
$this->setDescription('Installation process to use instead of web-ui');
|
$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->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)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
$result = self::SUCCESS;
|
$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();
|
session_start();
|
||||||
|
|
||||||
require __DIR__ . '/install.functions.php';
|
require __DIR__ . '/install.functions.php';
|
||||||
|
|||||||
@@ -404,8 +404,20 @@ class Install
|
|||||||
$default = 'bullseye';
|
$default = 'bullseye';
|
||||||
|
|
||||||
// read os-release
|
// read os-release
|
||||||
if (@file_exists('/etc/os-release')) {
|
if (@file_exists('/etc/os-release') && is_readable('/etc/os-release')) {
|
||||||
$os_dist = parse_ini_file('/etc/os-release', false);
|
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 strtolower($os_dist['VERSION_CODENAME'] ?? ($os_dist['ID'] ?? $default));
|
||||||
}
|
}
|
||||||
return $default;
|
return $default;
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ class Core
|
|||||||
$this->doDataEntries($pdo);
|
$this->doDataEntries($pdo);
|
||||||
// create JSON array for config-services
|
// create JSON array for config-services
|
||||||
$this->createJsonArray();
|
$this->createJsonArray();
|
||||||
|
$this->createUserdataParamStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUnprivilegedPdo(): PDO
|
public function getUnprivilegedPdo(): PDO
|
||||||
@@ -675,4 +676,23 @@ class Core
|
|||||||
];
|
];
|
||||||
$_SESSION['installation']['json_params'] = json_encode($json_params);
|
$_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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,9 +220,11 @@ return [
|
|||||||
'system' => [
|
'system' => [
|
||||||
'label' => lng('install.install.runcmd'),
|
'label' => lng('install.install.runcmd'),
|
||||||
'type' => 'textarea',
|
'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,
|
'readonly' => true,
|
||||||
'rows' => 3
|
'rows' => 10,
|
||||||
|
'style' => 'min-height:16rem;'
|
||||||
],
|
],
|
||||||
'manual_config' => [
|
'manual_config' => [
|
||||||
'label' => lng('install.install.manual_config'),
|
'label' => lng('install.install.manual_config'),
|
||||||
|
|||||||
@@ -201,7 +201,7 @@
|
|||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro textarea(id, field) %}
|
{% 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 %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro link(id, field) %}
|
{% macro link(id, field) %}
|
||||||
|
|||||||
Reference in New Issue
Block a user