mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2024-11-22 08:16:25 -06:00
Add support for LQOS_DIRECTORY environment variable overriding the
saved value when loading the config file. If LQOS_DIRECTORY is not set, nothing happens. If LQOS_DIRECTORY is set---for example with: ``` export LQOS_DIRECTORY="/opt/libreqos2" ``` Then the directory is overridden in the loaded configuration from the environment variable. This is designed to make it easier to have multiple instances---for example for building configuration and then distributing it.
This commit is contained in:
parent
78c2388501
commit
297bdcd58e
@ -43,8 +43,15 @@ pub fn load_config() -> Result<Config, LibreQoSConfigError> {
|
||||
config_result
|
||||
)));
|
||||
}
|
||||
let mut final_config = config_result.unwrap(); // We know it's good at this point
|
||||
|
||||
// Check for environment variable overrides
|
||||
if let Ok(lqos_dir) = std::env::var("LQOS_DIRECTORY") {
|
||||
final_config.lqos_directory = lqos_dir;
|
||||
}
|
||||
|
||||
log::info!("Set cached version of config file");
|
||||
*lock = Some(config_result.unwrap());
|
||||
*lock = Some(final_config);
|
||||
}
|
||||
|
||||
Ok(lock.as_ref().unwrap().clone())
|
||||
|
Loading…
Reference in New Issue
Block a user