mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Move Config loading to a service provider (#13927)
* Move Config loading to a service provider That way other service providers can depend on it Move various random listener registrations into the EventServiceProvider Various startup cleanup * Config::persist Set live variable before persisting incase db update fail * Disable strict mode for legacy code (init.php) * Disable debug after os test data is gathered * remove Eloquent::boot it is never used * remove Eloquent::version * lint fixes * style fixes * there is no c_echo here
This commit is contained in:
@@ -31,7 +31,6 @@ use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Data\Store\Rrd;
|
||||
use LibreNMS\DB\Eloquent;
|
||||
use LibreNMS\Util\Debug;
|
||||
use LibreNMS\Util\Version;
|
||||
use Log;
|
||||
@@ -254,11 +253,11 @@ class Config
|
||||
public static function persist($key, $value)
|
||||
{
|
||||
try {
|
||||
Arr::set(self::$config, $key, $value);
|
||||
\App\Models\Config::updateOrCreate(['config_name' => $key], [
|
||||
'config_name' => $key,
|
||||
'config_value' => $value,
|
||||
]);
|
||||
Arr::set(self::$config, $key, $value);
|
||||
|
||||
// delete any children (there should not be any unless it is legacy)
|
||||
\App\Models\Config::query()->where('config_name', 'like', "$key.%")->delete();
|
||||
@@ -338,10 +337,6 @@ class Config
|
||||
*/
|
||||
private static function loadDB()
|
||||
{
|
||||
if (! Eloquent::isConnected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
\App\Models\Config::get(['config_name', 'config_value'])
|
||||
->each(function ($item) {
|
||||
@@ -462,15 +457,10 @@ class Config
|
||||
self::persist('device_display_default', $display_value);
|
||||
}
|
||||
|
||||
$persist = Eloquent::isConnected();
|
||||
// make sure we have full path to binaries in case PATH isn't set
|
||||
foreach (['fping', 'fping6', 'snmpgetnext', 'rrdtool', 'traceroute', 'traceroute6'] as $bin) {
|
||||
if (! is_executable(self::get($bin))) {
|
||||
if ($persist) {
|
||||
self::persist($bin, self::locateBinary($bin));
|
||||
} else {
|
||||
self::set($bin, self::locateBinary($bin));
|
||||
}
|
||||
self::persist($bin, self::locateBinary($bin));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user