diff --git a/install/install.php b/install/install.php index fe47b30b..0a58398e 100644 --- a/install/install.php +++ b/install/install.php @@ -49,6 +49,7 @@ 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(); diff --git a/lib/Froxlor/Cli/ConfigServices.php b/lib/Froxlor/Cli/ConfigServices.php index c6118322..07902d0c 100644 --- a/lib/Froxlor/Cli/ConfigServices.php +++ b/lib/Froxlor/Cli/ConfigServices.php @@ -289,7 +289,7 @@ final class ConfigServices extends CliCommand $applyFile = $input->getOption('apply'); // check if plain JSON - $decoded_config = json_decode($applyFile); + $decoded_config = json_decode($applyFile, true); $skipFileCheck = false; if (json_last_error() == JSON_ERROR_NONE) { $skipFileCheck = true; diff --git a/lib/Froxlor/Install/Install.php b/lib/Froxlor/Install/Install.php index 50589494..588434f3 100644 --- a/lib/Froxlor/Install/Install.php +++ b/lib/Froxlor/Install/Install.php @@ -354,15 +354,8 @@ class Install ); // read os-release if (@file_exists('/etc/os-release')) { - $os_dist_content = file_get_contents('/etc/os-release'); - $os_dist_arr = explode("\n", $os_dist_content); - $os_dist = []; - foreach ($os_dist_arr as $os_dist_line) { - if (empty(trim($os_dist_line))) continue; - $tmp = explode("=", $os_dist_line); - $os_dist[$tmp[0]] = str_replace('"', "", trim($tmp[1])); - } - return strtolower($os_dist['VERSION_CODENAME']); + $os_dist = parse_ini_file('/etc/os-release', false); + return strtolower($os_dist['VERSION_CODENAME'] ?? ($os_dist['ID'] ?? null)); } return null; } diff --git a/lib/Froxlor/Install/Install/Core.php b/lib/Froxlor/Install/Install/Core.php index caa1b910..df4ec6e9 100644 --- a/lib/Froxlor/Install/Install/Core.php +++ b/lib/Froxlor/Install/Install/Core.php @@ -265,6 +265,13 @@ class Core */ private function grantDbPrivilegesTo(&$db_root, $database, $username, $password, $access_host) { + if ($this->validatedData['mysql_force_create']) { + $drop_stmt = $db_root->prepare("DROP USER :username@:host"); + $drop_stmt->execute([ + "username" => $username, + "host" => $access_host + ]); + } if (version_compare($db_root->getAttribute(PDO::ATTR_SERVER_VERSION), '10.0.0', '>=')) { // mariadb compatibility // create user @@ -417,17 +424,26 @@ class Core $this->updateSetting($upd_stmt, '1', 'phpfpm', 'enabled_ownvhost'); } elseif ($this->validatedData['webserver_backend'] == 'fcgid') { $this->updateSetting($upd_stmt, '1', 'system', 'mod_fcgid'); - $this->updateSetting($upd_stmt, '1', 'phpfpm', 'mod_fcgid_ownvhost'); + $this->updateSetting($upd_stmt, '1', 'system', 'mod_fcgid_ownvhost'); } // check currently used php version and set values of fpm/fcgid accordingly if (defined('PHP_MAJOR_VERSION') && defined('PHP_MINOR_VERSION')) { - // php-fpm - $reload = "service php" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "-fpm restart"; - $config_dir = "/etc/php/" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "/fpm/pool.d/"; + // @todo does not work for gentoo + if ($this->validatedData['distribution'] == 'gentoo') { + // php-fpm + $reload = "/etc/init.d/php-fpm restart"; + $config_dir = "/etc/php/fpm-php" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "/fpm.d/"; + // fcgid + $binary = "/usr/bin/php-cgi"; + } else { + // php-fpm + $reload = "service php" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "-fpm restart"; + $config_dir = "/etc/php/" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "/fpm/pool.d/"; + // fcgid + $binary = "/usr/bin/php" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "-cgi"; + } $db_user->query("UPDATE `" . TABLE_PANEL_FPMDAEMONS . "` SET `reload_cmd` = '" . $reload . "', `config_dir` = '" . $config_dir . "' WHERE `id` ='1';"); - // fcgid - $binary = "/usr/bin/php" . PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "-cgi"; $db_user->query("UPDATE `" . TABLE_PANEL_PHPCONFIGS . "` SET `binary` = '" . $binary . "';"); } @@ -611,7 +627,7 @@ class Core private function createJsonArray() { - $system_params= ["cron","libnssextrausers","logrotate"]; + $system_params = ["cron", "libnssextrausers", "logrotate"]; if ($this->validatedData['webserver_backend'] == 'php-fpm') { $system_params[] = 'php-fpm'; } elseif ($this->validatedData['webserver_backend'] == 'fcgid') { diff --git a/lib/configfiles/gentoo.xml b/lib/configfiles/gentoo.xml index 2d28e1f7..ddcfb20e 100644 --- a/lib/configfiles/gentoo.xml +++ b/lib/configfiles/gentoo.xml @@ -1590,7 +1590,7 @@ root: root@ title="Postfix 2 with dovecot"> //service[@type='smtp']/general/commands[@index=1] - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> //service[@type='smtp']/general/installs[@index=1] //service[@type='smtp']/general/commands[@index=2] @@ -1738,7 +1738,7 @@ dovecot unix - n n - - pipe title="Postfix 3 with dovecot" default="true"> //service[@type='smtp']/general/commands[@index=1] - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> //service[@type='smtp']/general/installs[@index=1] //service[@type='smtp']/general/commands[@index=2] @@ -1891,7 +1891,7 @@ dovecot unix - n n - - pipe title="Postfix 2 with courier"> //service[@type='smtp']/general/commands[@index=1] - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> //service[@type='smtp']/general/installs[@index=1] //service[@type='smtp']/general/commands[@index=2] @@ -2020,7 +2020,7 @@ sql_select: SELECT password_enc FROM mail_users WHERE username='%u@%r' OR email= - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> @@ -3424,7 +3424,7 @@ MAILDIRPATH=.maildir - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> @@ -3556,7 +3556,7 @@ UseReverseDNS off - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> @@ -3610,7 +3610,7 @@ MySQLGetQTASZ SELECT panel_customers.diskspace/1024 AS QuotaSize FROM panel_cu - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> @@ -3857,12 +3857,12 @@ aliases: files - > /etc/portage/package.use]]> - + > /etc/portage/package.use/froxlor]]> + {{settings.system.webserver}} - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> {{settings.system.webserver}} @@ -3894,12 +3894,12 @@ aliases: files - > /etc/portage/package.use]]> - + > /etc/portage/package.use/froxlor]]> + {{settings.system.webserver}} - > /etc/portage/package.use]]> + > /etc/portage/package.use/froxlor]]> {{settings.system.webserver}} diff --git a/lib/formfields/install/formfield.install.php b/lib/formfields/install/formfield.install.php index f73e714e..ee2fdc76 100644 --- a/lib/formfields/install/formfield.install.php +++ b/lib/formfields/install/formfield.install.php @@ -212,7 +212,7 @@ 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']['json_params']) ? Froxlor::getInstallDir() . "bin/froxlor-cli froxlor:config-services -a '" . $_SESSION['installation']['json_params'] . "' --yes-to-all" : "something went wrong...", 'readonly' => true, 'rows' => 1 ],