diff --git a/noxis-rs/src/options/preboot.rs b/noxis-rs/src/options/preboot.rs index fd22143..cf3e55d 100644 --- a/noxis-rs/src/options/preboot.rs +++ b/noxis-rs/src/options/preboot.rs @@ -38,16 +38,34 @@ impl std::fmt::Display for EnvVars { } } -impl Default for EnvVars { - fn default() { - todo!() - // setting default env vars values if not exists +// impl<'a> Default for EnvVars { +// fn default() -> &'a str { +// todo!() +// // setting default env vars values if not exists +// } +// } + +impl<'a> EnvVars { + // Default trait func is not satisfying this issue + fn default(self) -> &'a str { + match self { + EnvVars::NoxisNoHagent => "false", + EnvVars::NoxisNoLogs => "false", + EnvVars::NoxisRefreshLogs => "false", + EnvVars::NoxisNoRemoteConfig => "false", + EnvVars::NoxisNoConfigSub => "false", + EnvVars::NoxisSocketPath => "/var/run/enode/hostagent.sock", + EnvVars::NoxisLogTo => "./", + EnvVars::NoxisRemoteServerUrl => "localhost", + EnvVars::NoxisConfig => "./settings.json", + EnvVars::NoxisMetrics => "NOXIS_METRICS", + } } -} - -impl EnvVars { fn setup() { + // setup default if not exists + // check values and save preboot states in env vars if not equal + todo!() } } @@ -256,6 +274,10 @@ impl PrebootParams { // existing sock file if !self.config.exists() { eprintln!("Error: Invalid character in config file. Config path was set to default"); + let config = PathBuf::from("/etc/settings.json"); + if !config.exists() && self.no_remote_config { + return Err(Error::msg("Noxis cannot run without config. Create local config or enable remote-config mechanism")); + } self.config = PathBuf::from("settings.json"); // return Err(Error::msg("Local Config Not Found or Noxis can't read it. Cannot start")); }