summaryrefslogtreecommitdiffstats
path: root/crates/core/tedge_agent/src/agent.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/core/tedge_agent/src/agent.rs')
-rw-r--r--crates/core/tedge_agent/src/agent.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/core/tedge_agent/src/agent.rs b/crates/core/tedge_agent/src/agent.rs
index d4d723c8..69acdd40 100644
--- a/crates/core/tedge_agent/src/agent.rs
+++ b/crates/core/tedge_agent/src/agent.rs
@@ -227,13 +227,17 @@ impl SmAgent {
#[instrument(skip(self), name = "sm-agent")]
pub async fn init(&mut self, config_dir: PathBuf) -> Result<(), anyhow::Error> {
+ // `config_dir` by default is `/etc/tedge` (or whatever the user sets with --config-dir)
+ let config_dir = config_dir.display();
+ let log_path = self.config.log_dir.display();
+ create_directory_with_user_group(&format!("{config_dir}/.agent"), "tedge", "tedge", 0o775)?;
+ create_directory_with_user_group(&format!("{log_path}/tedge"), "tedge", "tedge", 0o775)?;
create_directory_with_user_group(
- format!("{}/.agent", config_dir.display()),
+ &format!("{log_path}/tedge/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?;