mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
finish conversion
This commit is contained in:
@@ -33,7 +33,7 @@ class FinalizeController extends InstallationController implements InstallerStep
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
if (!self::enabled($this->steps)) {
|
||||
if (!$this->enabled()) {
|
||||
return redirect()->route('install');
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ class FinalizeController extends InstallationController implements InstallerStep
|
||||
$config_message = file_exists($config_file) ? trans('install.finish.config_exists') : trans('install.finish.config_written');
|
||||
|
||||
try {
|
||||
$this->writeConfigFile($config, $config_file);
|
||||
$this->writeConfigFile();
|
||||
} catch (Exception $e) {
|
||||
$messages[] = $e->getMessage();
|
||||
$config_message = trans('install.finish.config_not_written');
|
||||
@@ -77,84 +77,34 @@ class FinalizeController extends InstallationController implements InstallerStep
|
||||
|
||||
private function writeEnvFile()
|
||||
{
|
||||
return EnvHelper::setEnv([
|
||||
$this->configureDatabase();
|
||||
$connection = config('database.default', $this->connection);
|
||||
return EnvHelper::tryWriteEnv([
|
||||
'NODE_ID' => uniqid(),
|
||||
'DB_HOST' => session('db.host'),
|
||||
'DB_PORT' => session('db.port'),
|
||||
'DB_USERNAME' => session('db.username'),
|
||||
'DB_PASSWORD' => session('db.password'),
|
||||
'DB_DATABASE' => session('db.database'),
|
||||
'DB_SOCKET' => session('db.socket'),
|
||||
'DB_HOST' => config("database.connections.$connection.host"),
|
||||
'DB_PORT' => config("database.connections.$connection.port"),
|
||||
'DB_USERNAME' => config("database.connections.$connection.username"),
|
||||
'DB_PASSWORD' => config("database.connections.$connection.password"),
|
||||
'DB_DATABASE' => config("database.connections.$connection.database"),
|
||||
'DB_SOCKET' => config("database.connections.$connection.unix_socket"),
|
||||
], ['INSTALL'], base_path('.env'));
|
||||
}
|
||||
|
||||
private function writeConfigFile($config_contents, $config_file)
|
||||
private function writeConfigFile()
|
||||
{
|
||||
if (!file_exists($config_file)) {
|
||||
$conf = fopen($config_file, 'w');
|
||||
if ($conf !== false) {
|
||||
if (fwrite($conf, "<?php\n") === false) {
|
||||
throw new Exception("We couldn't create the config.php file, please create this manually before continuing by copying the below into a config.php in the root directory of your install (typically /opt/librenms/)");
|
||||
}
|
||||
|
||||
$config_contents = stripslashes($config_contents);
|
||||
fwrite($conf, $config_contents);
|
||||
fclose($conf);
|
||||
return;
|
||||
}
|
||||
$config_file = base_path('config.php');
|
||||
if (file_exists($config_file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!copy(base_path('config.php.default'), $config_file)) {
|
||||
throw new Exception("We couldn't create the config.php file, please create this manually before continuing by copying the below into a config.php in the root directory of your install (typically /opt/librenms/)");
|
||||
}
|
||||
}
|
||||
|
||||
private function getConfigFileContents()
|
||||
{
|
||||
$db = session('db');
|
||||
$install_dir = base_path();
|
||||
|
||||
return <<<"EOD"
|
||||
## Have a look in defaults.inc.php for examples of settings you can set here. DO NOT EDIT defaults.inc.php!
|
||||
|
||||
### Database config
|
||||
\$config['db_host'] = '{$db['host']}';
|
||||
\$config['db_port'] = '{$db['port']}';
|
||||
\$config['db_user'] = '{$db['username']}';
|
||||
\$config['db_pass'] = '{$db['password']}';
|
||||
\$config['db_name'] = '{$db['database']}';
|
||||
\$config['db_socket'] = '{$db['unix_socket']}';
|
||||
|
||||
// This is the user LibreNMS will run as
|
||||
//Please ensure this user is created and has the correct permissions to your install
|
||||
\$config['user'] = 'librenms';
|
||||
|
||||
### Locations - it is recommended to keep the default
|
||||
#\$config['install_dir'] = "$install_dir";
|
||||
|
||||
### This should *only* be set if you want to *force* a particular hostname/port
|
||||
### It will prevent the web interface being usable form any other hostname
|
||||
#\$config['base_url'] = "http://librenms.company.com";
|
||||
|
||||
### Enable this to use rrdcached. Be sure rrd_dir is within the rrdcached dir
|
||||
### and that your web server has permission to talk to rrdcached.
|
||||
#\$config['rrdcached'] = "unix:/var/run/rrdcached.sock";
|
||||
|
||||
### Default community
|
||||
\$config['snmp']['community'] = ['public'];
|
||||
|
||||
### Authentication Model
|
||||
\$config['auth_mechanism'] = "mysql"; # default, other options: ldap, http-auth
|
||||
#\$config['http_auth_guest'] = "guest"; # remember to configure this user if you use http-auth
|
||||
|
||||
### List of RFC1918 networks to allow scanning-based discovery
|
||||
#\$config['nets'][] = "10.0.0.0/8";
|
||||
#\$config['nets'][] = "172.16.0.0/12";
|
||||
#\$config['nets'][] = "192.168.0.0/16";
|
||||
|
||||
# Update configuration
|
||||
#\$config['update_channel'] = 'release'; # uncomment to follow the monthly release channel
|
||||
#\$config['update'] = 0; # uncomment to completely disable updates
|
||||
EOD;
|
||||
|
||||
return file_get_contents(base_path('config.php.default'));
|
||||
}
|
||||
|
||||
public function enabled(): bool
|
||||
|
||||
Reference in New Issue
Block a user