From 3ee04a6e75fb43da90c71af897cce6cb0341266f Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Sat, 20 Aug 2022 13:44:44 +0200 Subject: [PATCH] install-finish-magic Signed-off-by: Michael Kaufmann --- actions/admin/settings/122.froxlorvhost.php | 2 +- install/froxlor.sql.php | 2 +- lib/Froxlor/UI/Panel/UI.php | 13 +++-- lib/formfields/install/formfield.install.php | 6 ++- lng/de.lng.php | 1 + lng/en.lng.php | 1 + templates/Froxlor/install/index.html.twig | 3 +- .../Froxlor/misc/ownershiphint.html.twig | 2 +- .../Froxlor/src/js/components/install.js | 47 ++++++++++++++++++- 9 files changed, 66 insertions(+), 11 deletions(-) diff --git a/actions/admin/settings/122.froxlorvhost.php b/actions/admin/settings/122.froxlorvhost.php index eb17552f..4f8c3871 100644 --- a/actions/admin/settings/122.froxlorvhost.php +++ b/actions/admin/settings/122.froxlorvhost.php @@ -42,7 +42,7 @@ return [ 'settinggroup' => 'system', 'varname' => 'froxlordirectlyviahostname', 'type' => 'checkbox', - 'default' => false, + 'default' => true, 'save_method' => 'storeSettingField' ], 'system_froxloraliases' => [ diff --git a/install/froxlor.sql.php b/install/froxlor.sql.php index 01f1d38d..a334844a 100644 --- a/install/froxlor.sql.php +++ b/install/froxlor.sql.php @@ -598,7 +598,7 @@ opcache.validate_timestamps'), ('system', 'ftpserver', 'proftpd'), ('system', 'dns_createmailentry', '0'), ('system', 'dns_createcaaentry', '1'), - ('system', 'froxlordirectlyviahostname', '0'), + ('system', 'froxlordirectlyviahostname', '1'), ('system', 'report_enable', '1'), ('system', 'report_webmax', '90'), ('system', 'report_trafficmax', '90'), diff --git a/lib/Froxlor/UI/Panel/UI.php b/lib/Froxlor/UI/Panel/UI.php index 0fc201ef..dd68d7ad 100644 --- a/lib/Froxlor/UI/Panel/UI.php +++ b/lib/Froxlor/UI/Panel/UI.php @@ -163,11 +163,14 @@ class UI self::$install_mode = $install_mode; // init twig template engine $loader = new FilesystemLoader(Froxlor::getInstallDir() . '/templates/'); - self::$twig = new Environment($loader, [ - 'debug' => true, - 'cache' => Froxlor::getInstallDir() . '/cache', - 'auto_reload' => true - ]); + $twig_params = [ + 'auto_reload' => true, + 'debug' => false, + ]; + if (is_writable(Froxlor::getInstallDir() . '/cache')) { + $twig_params['cache'] = Froxlor::getInstallDir() . '/cache'; + } + self::$twig = new Environment($loader, $twig_params); self::$twig->addExtension(new DebugExtension()); self::$twig->addExtension(new CustomReflection()); self::$twig->addExtension(new FroxlorTwig()); diff --git a/lib/formfields/install/formfield.install.php b/lib/formfields/install/formfield.install.php index 4b34b939..9a424d06 100644 --- a/lib/formfields/install/formfield.install.php +++ b/lib/formfields/install/formfield.install.php @@ -231,7 +231,11 @@ return [ 'type' => 'checkbox', 'value' => '1', 'checked' => old('manual_config', '0', 'installation'), - ] + ], + 'target_servername' => [ + 'type' => 'hidden', + 'value' => $_SESSION['installation']['servername'] ?? "", + ], ] ] ] diff --git a/lng/de.lng.php b/lng/de.lng.php index 71c244a0..bb913aa7 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -2169,6 +2169,7 @@ Vielen Dank, Ihr Administrator', 'description' => 'Der untenstehende Befehl lädt, installiert und konfiguriert die benötigten Dienste auf dem System aufgrund der Angaben die während des Installationsprozessen gesammelt wurden.', 'runcmd' => 'Folgenden Befehl als root-Benutzer in der Shell auf dem Server ausführen:', 'manual_config' => 'Ich werden die Dienste manuell konfigurieren, direkt zum Login umleiten', + 'waitforconfig' => 'Warte auf Abschluss der Dienstkonfiguration...', ], 'errors' => [ 'wrong_ownership' => 'Die froxlor Dateien gehören nicht vollständig dem Benutzer %s:%s', diff --git a/lng/en.lng.php b/lng/en.lng.php index ac6fcc82..8aad9f02 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -2555,6 +2555,7 @@ Yours sincerely, your administrator', 'description' => 'The command below will download, install and configure required services on your system according to the data you have given in this installation process.', 'runcmd' => 'Run the following command as root-user in your shell on this server:', 'manual_config' => 'I will manually configure the services, just take me to the login', + 'waitforconfig' => 'Waiting for services to be configured...', ], 'errors' => [ 'wrong_ownership' => 'Make sure the froxlor files are owned by %s:%s', diff --git a/templates/Froxlor/install/index.html.twig b/templates/Froxlor/install/index.html.twig index 96ded525..2aa7c078 100644 --- a/templates/Froxlor/install/index.html.twig +++ b/templates/Froxlor/install/index.html.twig @@ -60,7 +60,8 @@ « {{ lng('panel.back') }} {% else %} - + {{ lng('install.install.waitforconfig') }} + {% endif %} {% else %} diff --git a/templates/Froxlor/misc/ownershiphint.html.twig b/templates/Froxlor/misc/ownershiphint.html.twig index be6b3401..a1f63ee9 100644 --- a/templates/Froxlor/misc/ownershiphint.html.twig +++ b/templates/Froxlor/misc/ownershiphint.html.twig @@ -11,7 +11,7 @@
chown -R {{ user }}:{{ group }} {{ installdir }}

- Start install + Reload

diff --git a/templates/Froxlor/src/js/components/install.js b/templates/Froxlor/src/js/components/install.js index 9c29a4a1..4f076252 100644 --- a/templates/Froxlor/src/js/components/install.js +++ b/templates/Froxlor/src/js/components/install.js @@ -4,7 +4,7 @@ $(function () { */ $('#switchInstallMode').on('click', function () { var checked = $(this).prop('checked'); - window.location = '/install/install.php' + replaceQueryParam('extended', +checked, window.location.search); + window.location = window.location.pathname + replaceQueryParam('extended', +checked, window.location.search); }); function replaceQueryParam(param, newval, search) { @@ -14,4 +14,49 @@ $(function () { } return search + '&' + param + '=' + newval; } + + function checkConfigState() { + $.ajax({ + url: window.location.href, + type: "GET", + success: function (data, textStatus, request) { + if (request.status >= 300) { + window.location = "http://" + srvName; + } + }, + error: function (request, textStatus, errorThrown) { + // continue + if (request.status >= 300) { + window.location = "http://" + srvName; + } + } + }); + } + + var cTimer; + + /** + * check manual-config switch + */ + $('#manual_config').on('click', function () { + clearInterval(cTimer); + var checked = $(this).prop('checked'); + if (checked) { + // button zum login + $('#submitAuto').addClass('d-none'); + $('#submitManual').removeClass('d-none'); + } else { + cTimer = setInterval(checkConfigState, 1000); + // spinner fürs warten + $('#submitAuto').removeClass('d-none'); + $('#submitManual').addClass('d-none'); + } + }); + + if ($('#manual_config').length > 0) { + var srvName = $('#target_servername').val(); + clearInterval(cTimer); + cTimer = setInterval(checkConfigState, 1000); + } + });