diff options
Diffstat (limited to 'crates/core/tedge_agent/src/agent.rs')
-rw-r--r-- | crates/core/tedge_agent/src/agent.rs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/crates/core/tedge_agent/src/agent.rs b/crates/core/tedge_agent/src/agent.rs index df41368f..b7c7ba27 100644 --- a/crates/core/tedge_agent/src/agent.rs +++ b/crates/core/tedge_agent/src/agent.rs @@ -20,9 +20,9 @@ use serde_json::json; use std::process; use std::{convert::TryInto, fmt::Debug, path::PathBuf, sync::Arc}; use tedge_config::{ - ConfigRepository, ConfigSettingAccessor, ConfigSettingAccessorStringExt, LogPathDefaultSetting, - MqttBindAddressSetting, MqttPortSetting, RunPathDefaultSetting, SoftwarePluginDefaultSetting, - TEdgeConfigLocation, TmpPathDefaultSetting, DEFAULT_LOG_PATH, DEFAULT_RUN_PATH, + ConfigRepository, ConfigSettingAccessor, ConfigSettingAccessorStringExt, LogPathSetting, + MqttBindAddressSetting, MqttPortSetting, RunPathSetting, SoftwarePluginDefaultSetting, + TEdgeConfigLocation, TmpPathSetting, DEFAULT_LOG_PATH, DEFAULT_RUN_PATH, }; use tedge_utils::file::create_directory_with_user_group; use tokio::sync::Mutex; @@ -139,11 +139,11 @@ impl SmAgentConfig { .tedge_config_root_path() .to_path_buf(); - let tedge_download_dir = tedge_config.query_string(TmpPathDefaultSetting)?.into(); + let tedge_download_dir = tedge_config.query_string(TmpPathSetting)?.into(); - let tedge_log_dir: String = tedge_config.query_string(LogPathDefaultSetting)?.into(); + let tedge_log_dir: String = tedge_config.query_string(LogPathSetting)?.into(); let tedge_log_dir = PathBuf::from(&format!("{tedge_log_dir}/{AGENT_LOG_PATH}")); - let tedge_run_dir = tedge_config.query_string(RunPathDefaultSetting)?.into(); + let tedge_run_dir = tedge_config.query_string(RunPathSetting)?.into(); Ok(SmAgentConfig::default() .with_sm_home(tedge_config_path) @@ -224,14 +224,10 @@ impl SmAgent { } #[instrument(skip(self), name = "sm-agent")] - pub async fn init(&mut self) -> Result<(), anyhow::Error> { - create_directory_with_user_group("/etc/tedge/.agent", "tedge-agent", "tedge-agent", 0o775)?; - create_directory_with_user_group( - "/var/log/tedge/agent", - "tedge-agent", - "tedge-agent", - 0o775, - )?; + pub async fn init(&mut self, config_dir: PathBuf) -> Result<(), anyhow::Error> { + let cfg_dir = config_dir.as_path().display().to_string(); + create_directory_with_user_group(&format!("{cfg_dir}/.agent"), "tedge", "tedge", 0o775)?; + create_directory_with_user_group("/var/log/tedge/agent", "tedge", "tedge", 0o775)?; info!("Initializing the tedge agent session"); mqtt_channel::init_session(&self.config.mqtt_config).await?; |