mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Check correct path for config in the installer (#10333)
* Check ../config.php for older installations in installer For older installations, install.php is still available for installations that have the configuration file in the parent directory. This PR fixes this. * Replace relative directory with absolute path * Update install.php * Update install.php
This commit is contained in:
committed by
Tony Murray
parent
da9e67b296
commit
2ee843d86b
@ -2,9 +2,11 @@
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
session_start();
|
||||
$librenms_dir = realpath(__DIR__ . '/..');
|
||||
|
||||
if (empty($_POST) && !empty($_SESSION) && !isset($_REQUEST['stage'])) {
|
||||
$_POST = $_SESSION;
|
||||
} elseif (!file_exists("config.php")) {
|
||||
} elseif (!file_exists("{$librenms_dir}/config.php")) {
|
||||
$allowed_vars = array('stage','build-ok','dbhost','dbuser','dbpass','dbname','dbport','dbsocket','add_user','add_pass','add_email');
|
||||
foreach ($allowed_vars as $allowed) {
|
||||
if (isset($_POST[$allowed])) {
|
||||
@ -16,7 +18,7 @@ if (empty($_POST) && !empty($_SESSION) && !isset($_REQUEST['stage'])) {
|
||||
$stage = isset($_POST['stage']) ? $_POST['stage'] : 0;
|
||||
|
||||
// Before we do anything, if we see config.php, redirect back to the homepage.
|
||||
if (file_exists('config.php') && $stage != 6) {
|
||||
if (file_exists("{$librenms_dir}/config.php") && $stage != 6) {
|
||||
unset($_SESSION['stage']);
|
||||
header("Location: /");
|
||||
exit;
|
||||
@ -78,7 +80,7 @@ if ($stage == 4) {
|
||||
}
|
||||
} elseif ($stage == 6) {
|
||||
// If we get here then let's do some final checks.
|
||||
if (!file_exists("config.php")) {
|
||||
if (!file_exists("{$librenms_dir}/config.php")) {
|
||||
// config.php file doesn't exist. go back to that stage
|
||||
$msg = "config.php still doesn't exist";
|
||||
$stage = 5;
|
||||
@ -392,7 +394,7 @@ $config_file = <<<"EOD"
|
||||
#\$config\['update'\] = 0; # uncomment to completely disable updates
|
||||
EOD;
|
||||
|
||||
if (!file_exists("config.php")) {
|
||||
if (!file_exists("{$librenms_dir}/config.php")) {
|
||||
$conf = fopen("config.php", 'w');
|
||||
if ($conf != false) {
|
||||
if (fwrite($conf, "<?php\n") === false) {
|
||||
|
Reference in New Issue
Block a user