From 73e1ba65ca1edad1a12becbfe8ccee5b61e77e2a Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 23 Jul 2021 08:10:55 +0200 Subject: [PATCH] restore daemon: add setup_system_env helper Signed-off-by: Thomas Lamprecht --- src/bin/proxmox-restore-daemon.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/bin/proxmox-restore-daemon.rs b/src/bin/proxmox-restore-daemon.rs index ebe8cef5..5456bd23 100644 --- a/src/bin/proxmox-restore-daemon.rs +++ b/src/bin/proxmox-restore-daemon.rs @@ -50,9 +50,7 @@ fn main() -> Result<(), Error> { .format_timestamp_millis() .init(); - // the API may save some stuff there, e.g., the memcon tracking file - // we do not care much, but it's way less headache to just create it - std::fs::create_dir_all("/run/proxmox-backup")?; + setup_system_env()?; // scan all attached disks now, before starting the API // this will panic and stop the VM if anything goes wrong @@ -66,6 +64,15 @@ fn main() -> Result<(), Error> { pbs_runtime::main(run()) } +/// ensure we have our /run dirs, system users and stuff like that setup +fn setup_system_env() -> Result<(), Error> { + // the API may save some stuff there, e.g., the memcon tracking file + // we do not care much, but it's way less headache to just create it + std::fs::create_dir_all("/run/proxmox-backup")?; + + Ok(()) +} + async fn run() -> Result<(), Error> { watchdog_init();