krata/guest/bin/init.rs

25 lines
810 B
Rust
Raw Normal View History

use anyhow::{anyhow, Result};
use env_logger::Env;
use krataguest::init::GuestInit;
use std::env;
2024-01-17 16:18:12 +00:00
#[tokio::main]
async fn main() -> Result<()> {
env::set_var("RUST_BACKTRACE", "1");
2024-02-01 12:20:13 +00:00
env_logger::Builder::from_env(Env::default().default_filter_or("warn")).init();
2024-02-21 20:57:46 +00:00
if env::var("KRATA_UNSAFE_ALWAYS_ALLOW_INIT").unwrap_or("0".to_string()) != "1" {
let pid = std::process::id();
if pid > 3 {
return Err(anyhow!(
"not running because the pid of {} indicates this is probably not \
the right context for the init daemon. \
2024-02-21 20:57:46 +00:00
run with KRATA_UNSAFE_ALWAYS_ALLOW_INIT=1 to bypass this check",
pid
));
}
}
let mut guest = GuestInit::new();
guest.init().await?;
2024-01-17 16:18:12 +00:00
Ok(())
}