From e3f83ebe8e81ae8a409cb3345efe373503c11517 Mon Sep 17 00:00:00 2001 From: networkException Date: Thu, 12 Sep 2024 02:53:08 +0200 Subject: [PATCH] Main: Add command line option to make the process idle indefinitely --- src/main.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.rs b/src/main.rs index d047213..b174345 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use std::env; use std::fs; use std::path::PathBuf; +use std::thread; use anyhow::Result; @@ -18,12 +19,18 @@ struct Arguments { /// The path to write the built secret file to output_path: PathBuf, + + /// If the process should keep running without doing anything. This is used to keep a systemd service + /// running this and the associated RuntimeDirectory alive. + #[clap(long, default_value_t = false)] + idle: bool, } fn main() -> Result<()> { let Arguments { contents_path, output_path, + idle } = Arguments::parse(); let mut handlebars = Handlebars::new(); @@ -91,5 +98,11 @@ fn main() -> Result<()> { fs::write(&output_path, output) .expect(format!("To be able to write to '{}'", output_path.to_string_lossy()).as_str()); + if idle { + loop { + thread::park(); + } + } + Ok(()) }