Dependencies+Main: Add sd-notify and idle feature back
This patch reverts6959e6c3a6
,32a2492425
and7f7b6b4e29
on top of the current tree, adding back their features.
This commit is contained in:
parent
83cfd6b83f
commit
945a287841
3 changed files with 28 additions and 0 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -288,6 +288,15 @@ version = "1.0.18"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
|
||||
[[package]]
|
||||
name = "sd-notify"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b943eadf71d8b69e661330cb0e2656e31040acf21ee7708e2c238a0ec6af2bf4"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "secrets-file-builder"
|
||||
version = "0.6.0"
|
||||
|
@ -295,6 +304,7 @@ dependencies = [
|
|||
"anyhow",
|
||||
"clap",
|
||||
"handlebars",
|
||||
"sd-notify",
|
||||
"serde_json",
|
||||
"url-escape",
|
||||
]
|
||||
|
|
|
@ -12,5 +12,6 @@ repository = "https://git.nwex.de/networkException/secrets-file-builder"
|
|||
anyhow = "1.0.88"
|
||||
clap = { version = "4.5.17", features = ["derive"] }
|
||||
handlebars = "5.1.0"
|
||||
sd-notify = "0.4.5"
|
||||
serde_json = "1.0.114"
|
||||
url-escape = "0.1.1"
|
||||
|
|
17
src/main.rs
17
src/main.rs
|
@ -1,6 +1,7 @@
|
|||
use std::env;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::thread;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
|
@ -8,6 +9,8 @@ use clap::Parser;
|
|||
use serde_json::{Map, Value};
|
||||
use url_escape;
|
||||
|
||||
use sd_notify::NotifyState;
|
||||
|
||||
use handlebars::{Context, Handlebars, Helper, HelperResult, JsonRender, Output, RenderContext, RenderErrorReason};
|
||||
|
||||
#[derive(clap::Parser)]
|
||||
|
@ -18,12 +21,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();
|
||||
|
@ -96,5 +105,13 @@ fn main() -> Result<()> {
|
|||
|
||||
println!("Wrote secret file to '{}'", output_path.to_string_lossy());
|
||||
|
||||
sd_notify::notify(true, &[NotifyState::Ready])?;
|
||||
|
||||
if idle {
|
||||
loop {
|
||||
thread::park();
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue