diff --git a/lib/Froxlor/Cron/Http/Apache.php b/lib/Froxlor/Cron/Http/Apache.php index 0777ee71..b3e1e264 100644 --- a/lib/Froxlor/Cron/Http/Apache.php +++ b/lib/Froxlor/Cron/Http/Apache.php @@ -36,6 +36,7 @@ use Froxlor\Http\Statistics; use Froxlor\PhpHelper; use Froxlor\Settings; use Froxlor\Validate\Validate; +use Froxlor\System\Crypt; use PDO; /** @@ -351,9 +352,8 @@ class Apache extends HttpConfigBase if (($row_ipsandports['ssl_cert_file'] == '' || !file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) { $row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); if (!file_exists($row_ipsandports['ssl_cert_file'])) { - // explicitly disable ssl for this vhost - $row_ipsandports['ssl_cert_file'] = ""; - FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"'); + FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...'); + Crypt::createSelfSignedCertificate(); } } diff --git a/lib/Froxlor/Cron/Http/Lighttpd.php b/lib/Froxlor/Cron/Http/Lighttpd.php index 9342630b..3e0ac959 100644 --- a/lib/Froxlor/Cron/Http/Lighttpd.php +++ b/lib/Froxlor/Cron/Http/Lighttpd.php @@ -35,6 +35,7 @@ use Froxlor\Http\Directory; use Froxlor\Http\Statistics; use Froxlor\Settings; use Froxlor\Validate\Validate; +use Froxlor\System\Crypt; use PDO; /** @@ -212,9 +213,16 @@ class Lighttpd extends HttpConfigBase if (($row_ipsandports['ssl_cert_file'] == '' || !file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) { $row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); if (!file_exists($row_ipsandports['ssl_cert_file'])) { + $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...'); + Crypt::createSelfSignedCertificate(); + } + } + if ($row_ipsandports['ssl_key_file'] == '') { + $row_ipsandports['ssl_key_file'] = Settings::Get('system.ssl_key_file'); + if (!file_exists($row_ipsandports['ssl_key_file'])) { // explicitly disable ssl for this vhost $row_ipsandports['ssl_cert_file'] = ""; - $this->logger->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"'); + FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate key-file "' . Settings::Get('system.ssl_key_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"'); } } diff --git a/lib/Froxlor/Cron/Http/Nginx.php b/lib/Froxlor/Cron/Http/Nginx.php index 9a36379b..b5b7d05d 100644 --- a/lib/Froxlor/Cron/Http/Nginx.php +++ b/lib/Froxlor/Cron/Http/Nginx.php @@ -35,6 +35,7 @@ use Froxlor\Http\Directory; use Froxlor\Http\Statistics; use Froxlor\Settings; use Froxlor\Validate\Validate; +use Froxlor\System\Crypt; use PDO; class Nginx extends HttpConfigBase @@ -110,9 +111,8 @@ class Nginx extends HttpConfigBase if (($row_ipsandports['ssl_cert_file'] == '' || !file_exists($row_ipsandports['ssl_cert_file'])) && (Settings::Get('system.le_froxlor_enabled') == '0' || $this->froxlorVhostHasLetsEncryptCert() == false)) { $row_ipsandports['ssl_cert_file'] = Settings::Get('system.ssl_cert_file'); if (!file_exists($row_ipsandports['ssl_cert_file'])) { - // explicitly disable ssl for this vhost - $row_ipsandports['ssl_cert_file'] = ""; - FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Disabling SSL-vhost for "' . Settings::Get('system.hostname') . '"'); + FroxlorLogger::getInstanceOf()->logAction(FroxlorLogger::CRON_ACTION, LOG_DEBUG, 'System certificate file "' . Settings::Get('system.ssl_cert_file') . '" does not seem to exist. Creating self-signed certificate...'); + Crypt::createSelfSignedCertificate(); } } if ($row_ipsandports['ssl_key_file'] == '') { diff --git a/lib/Froxlor/Install/Install.php b/lib/Froxlor/Install/Install.php index b982b25c..3f949636 100644 --- a/lib/Froxlor/Install/Install.php +++ b/lib/Froxlor/Install/Install.php @@ -29,6 +29,7 @@ use Exception; use Froxlor\Install\Install\Core; use Froxlor\UI\Panel\UI; use Froxlor\UI\Request; +use Froxlor\Config\ConfigParser; class Install { @@ -42,18 +43,29 @@ class Install public array $suggestions = []; public array $criticals = []; public array $loadedExtensions; - // TODO: add more os - public array $supportedOS = [ - 'focal' => 'Ubuntu 20.04 LTS (Focal Fossa)' - ]; + public array $supportedOS = []; public array $webserverBackend = [ 'php-fpm' => 'PHP-FPM', 'fcgid' => 'FCGID', - 'none' => 'None', + 'mod_php' => 'mod_php (not recommended)', ]; public function __construct() { + // get all supported OS + // show list of available distro's + $distros = glob(dirname(__DIR__, 3) . '/lib/configfiles/*.xml'); + $distributions_select[''] = '-'; + // read in all the distros + foreach ($distros as $distribution) { + // get configparser object + $dist = new ConfigParser($distribution); + // store in tmp array + $this->supportedOS[str_replace(".xml", "", strtolower(basename($distribution)))] = $dist->getCompleteDistroName(); + } + // sort by distribution name + asort($this->supportedOS); + // set formfield, so we can get the fields and steps etc. $this->formfield = require dirname(__DIR__, 3) . '/lib/formfields/install/formfield.install.php'; @@ -131,7 +143,7 @@ class Install } // also handle completion of installation if it's the step before the last step - if ($this->currentStep == ($this->maxSteps -1)) { + if ($this->currentStep == ($this->maxSteps - 1)) { $core = new Core($_SESSION['installation']); $core->doInstall(); } @@ -180,10 +192,10 @@ class Install private function getInformationText(): string { if (version_compare($this->requiredVersion, PHP_VERSION, "<")) { - $text = 'Your system is running with PHP ' . $this->phpVersion; + $text = lng('install.phpinfosuccess', [$this->phpVersion]); } else { - $text = 'Your system is running a lower version than PHP ' . $this->requiredVersion; - $this->criticals[] = 'Update your current PHP Version from ' . $this->phpVersion . ' to ' . $this->requiredVersion . ' or higher'; + $text = lng('install.phpinfowarn', [$this->requiredVersion]); + $this->criticals[] = lng('install.phpinfoupdate', [$this->phpVersion, $this->requiredVersion]); } return $text; } diff --git a/lib/formfields/install/formfield.install.php b/lib/formfields/install/formfield.install.php index 82d93f0a..f70c44ba 100644 --- a/lib/formfields/install/formfield.install.php +++ b/lib/formfields/install/formfield.install.php @@ -23,29 +23,29 @@ * @license https://files.froxlor.org/misc/COPYING.txt GPLv2 */ +use Froxlor\Froxlor; + return [ 'install' => [ - 'title' => lng('admin.admin_add'), - 'image' => 'fa-solid fa-user-plus', - 'self_overview' => ['section' => 'admins', 'page' => 'admins'], + 'title' => 'install', 'sections' => [ 'step1' => [ 'title' => lng('install.database.title'), 'fields' => [ 'mysql_host' => [ - 'label' => lng('mysql_host'), + 'label' => lng('mysql.mysql_server'), 'type' => 'text', 'mandatory' => true, 'value' => old('mysql_host', 'localhost', 'installation') ], 'mysql_root_user' => [ - 'label' => lng('mysql_root_user'), + 'label' => lng('mysql.privileged_user'), 'type' => 'text', 'mandatory' => true, 'value' => old('mysql_root_user', 'froxroot', 'installation'), 'next_to' => [ 'mysql_root_pass' => [ - 'label' => lng('mysql_root_pass'), + 'label' => lng('login.password'), 'type' => 'password', 'mandatory' => true, 'value' => old('mysql_root_pass', null, 'installation'), @@ -53,13 +53,13 @@ return [ ] ], 'mysql_unprivileged_user' => [ - 'label' => lng('mysql_unprivileged_user'), + 'label' => lng('install.database.user'), 'type' => 'text', 'mandatory' => true, 'value' => old('mysql_unprivileged_user', 'froxlor', 'installation'), 'next_to' => [ 'mysql_unprivileged_pass' => [ - 'label' => lng('mysql_unprivileged_pass'), + 'label' => lng('login.password'), 'type' => 'password', 'mandatory' => true, 'value' => old('mysql_unprivileged_pass', null, 'installation'), @@ -67,48 +67,42 @@ return [ ] ], 'mysql_database' => [ - 'label' => lng('mysql_database'), + 'label' => lng('install.database.dbname'), 'type' => 'text', 'mandatory' => true, 'value' => old('mysql_database', 'froxlor', 'installation'), ], 'mysql_force_create' => [ - 'label' => lng('mysql_force_create'), + 'label' => lng('install.database.force_create'), 'type' => 'checkbox', 'value' => '1', 'checked' => old('mysql_force_create', '0', 'installation') ], - 'mysql_access_host' => [ - 'label' => lng('mysql_access_host'), - 'type' => 'text', - 'mandatory' => true, - 'value' => old('mysql_access_host', '127.0.0.1,localhost', 'installation'), - ], ] ], 'step2' => [ 'title' => lng('install.admin.title'), 'fields' => [ 'admin_name' => [ - 'label' => lng('admin_name'), + 'label' => lng('customer.name'), 'type' => 'text', 'mandatory' => true, 'value' => old('admin_name', 'Administrator', 'installation'), ], 'admin_user' => [ - 'label' => lng('admin_user'), + 'label' => lng('login.username'), 'type' => 'text', 'mandatory' => true, 'value' => old('admin_user', 'admin', 'installation'), ], 'admin_pass' => [ - 'label' => lng('admin_pass'), + 'label' => lng('login.password'), 'type' => 'password', 'mandatory' => true, 'value' => old('admin_pass', null, 'installation'), ], 'admin_email' => [ - 'label' => lng('admin_email'), + 'label' => lng('customer.email'), 'type' => 'text', 'mandatory' => true, 'value' => old('admin_email', null, 'installation'), @@ -119,55 +113,56 @@ return [ 'title' => lng('install.system.title'), 'fields' => [ 'distribution' => [ - 'label' => lng('distribution'), + 'label' => lng('admin.configfiles.distribution'), 'type' => 'select', 'mandatory' => true, 'select_var' => $this->supportedOS, ], 'serverip' => [ - 'label' => lng('serverip'), + 'label' => lng('serversettings.ipaddress.title'), 'type' => 'text', 'mandatory' => true, 'value' => old('serverip', null, 'installation'), ], 'servername' => [ - 'label' => lng('servername'), + 'label' => lng('install.system.servername'), 'type' => 'text', 'mandatory' => true, 'value' => old('servername', null, 'installation'), ], 'use_ssl' => [ - 'label' => lng('use_ssl'), + 'label' => lng('serversettings.ssl.use_ssl.title'), 'type' => 'checkbox', 'value' => '1', 'checked' => old('use_ssl', '1', 'installation'), ], 'webserver' => [ - 'label' => lng('webserver'), - 'type' => 'text', + 'label' => lng('admin.webserver'), + 'type' => 'select', 'mandatory' => true, + 'select_var' => ['apache24' => 'Apache 2.4', 'nginx' => 'Nginx', 'lighttpd' => 'LigHTTPd'], 'value' => old('webserver', 'apache24', 'installation'), ], 'webserver_backend' => [ - 'label' => lng('webserver_backend'), + 'label' => lng('install.system.phpbackend'), 'type' => 'select', 'mandatory' => true, 'select_var' => $this->webserverBackend, ], 'httpuser' => [ - 'label' => lng('httpuser'), + 'label' => lng('admin.webserver_user'), 'type' => 'text', 'mandatory' => true, 'value' => old('httpuser', 'www-data', 'installation'), ], 'httpgroup' => [ - 'label' => lng('httpgroup'), + 'label' => lng('admin.webserver_group'), 'type' => 'text', 'mandatory' => true, 'value' => old('httpgroup', 'www-data', 'installation'), ], 'activate_newsfeed' => [ - 'label' => lng('activate_newsfeed'), + 'label' => lng('install.system.activate_newsfeed'), 'type' => 'checkbox', 'value' => '1', 'checked' => false @@ -178,9 +173,9 @@ return [ 'title' => lng('install.system.title'), 'fields' => [ 'system' => [ - 'label' => lng('install.system.system'), + 'label' => lng('install.install.runcmd'), 'type' => 'textarea', - 'value' => '/var/www/html/froxlor/bin/froxlor-cli cron --force', + 'value' => Froxlor::getInstallDir().'bin/froxlor-cli froxlor:config-services -a [JSON PARAMETER] --yes-to-all', 'readonly' => true, 'rows' => 1 ], diff --git a/lng/en.lng.php b/lng/en.lng.php index 25afa999..ec9692ff 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -1368,6 +1368,7 @@ Yours sincerely, your administrator', 'mysql_server' => 'MySQL-Server', 'database_edit' => 'Edit database', 'size' => 'Size', + 'privileged_user' => 'Privileged database user', ], 'opcacheinfo' => [ 'generaltitle' => 'General Information', @@ -2453,9 +2454,41 @@ Yours sincerely, your administrator', ], ], 'install' => [ + 'slogal' => 'froxlor Server Management Panel', + 'preflight' => 'System check', + 'critical_error' => 'Critical error', + 'suggestions' => 'Not required but recommended', + 'phpinfosuccess' => 'Your system is running with PHP %s', + 'phpinfowarn' => 'Your system is running a lower version than PHP %s', + 'phpinfoupdate' => 'Update your current PHP Version from %s to %s or higher', + 'start_installation' => 'Start installation', + 'check_again' => 'Reload to check again', 'dependency_check' => [ 'title' => 'Welcome to froxlor', 'description' => 'We check the system for dependencies to ensure that all required php extensions and modules are enabled so that froxlor runs properly.', ], + 'database' => [ + 'top' => 'Database', + 'title' => 'Froxlor requires a database and additionally a privileged user to be able to create users and databases (GRANT option). The given database and unprivileged database-user will be created in this process. The privileged user must exist.', + 'user' => 'Unprivileged database user', + 'dbname' => 'Database name', + 'force_create' => 'Backup and overwrite database if exists?', + ], + 'admin' => [ + 'top' => 'Admin user', + 'title' => 'Let\'s create the main administrator user. This user has all privileges to adjust settings and add/update/delete resources like customers, domains, etc.', + ], + 'system' => [ + 'top' => 'System setup', + 'title' => 'Set your environment as well as server relevant data and options here to let froxlor know about your system. These values are crucial for the system configuration and operating.', + 'servername' => 'Server name (FQDN, no ip-address)', + 'phpbackend' => 'PHP backend', + 'activate_newsfeed' => 'Enable the official newsfeed
(https://inside.froxlor.org/news/)', + ], + 'install' => [ + 'top' => 'Finish setup', + 'title' => '@todo description', + 'runcmd' => 'Run the following command as root-user in your shell on this server to install/configure all services', + ], ], ]; diff --git a/templates/Froxlor/form/formfields.html.twig b/templates/Froxlor/form/formfields.html.twig index 20142785..29dba964 100644 --- a/templates/Froxlor/form/formfields.html.twig +++ b/templates/Froxlor/form/formfields.html.twig @@ -63,7 +63,7 @@ {% macro field(id, field, norow = true, nohide = false, em = false) %}
- + {{ _self.fieldrow(id, field, norow, nohide, em) }}
{% endmacro %} diff --git a/templates/Froxlor/install/index.html.twig b/templates/Froxlor/install/index.html.twig index 43cf0e80..0f3ca60d 100644 --- a/templates/Froxlor/install/index.html.twig +++ b/templates/Froxlor/install/index.html.twig @@ -2,7 +2,7 @@ {% block content %}
- {{ lng('slogan') }} + {{ lng('install.slogan') }} {% if error is not null %}
{{ error }}
@@ -11,23 +11,23 @@
- {% if setup.step > 0 %}{{ lng('preflight') }}{% else %}{{ lng('preflight') }}{% endif %} + {% if setup.step > 0 %}{{ lng('install.preflight') }}{% else %}{{ lng('install.preflight') }}{% endif %}
- {% if setup.step > 1 %}{{ lng('database') }}{% else %}{{ lng('database') }}{% endif %} + {% if setup.step > 1 %}{{ lng('install.database.top') }}{% else %}{{ lng('install.database.top') }}{% endif %}
- {% if setup.step > 2 %}{{ lng('admin') }}{% else %}{{ lng('admin') }}{% endif %} + {% if setup.step > 2 %}{{ lng('install.admin.top') }}{% else %}{{ lng('install.admin.top') }}{% endif %}
- {% if setup.step > 3 %}{{ lng('system') }}{% else %}{{ lng('system') }}{% endif %} + {% if setup.step > 3 %}{{ lng('install.system.top') }}{% else %}{{ lng('install.system.top') }}{% endif %}
- {% if setup.step > 4 %}{{ lng('install') }}{% else %}{{ lng('install') }}{% endif %} + {% if setup.step > 4 %}{{ lng('install.install.top') }}{% else %}{{ lng('install.install.top') }}{% endif %}
@@ -45,20 +45,20 @@ {% endfor %}
- « {{ lng('back') }} - + « {{ lng('panel.back') }} +
{% else %}

{{ lng('install.dependency_check.title') }}

{{ lng('install.dependency_check.description') }}

- + {{ preflight.text }}

{% if preflight.criticals %} -

{{ lng('critical_error') }}

+

{{ lng('install.critical_error') }}