karapace/crates/karapace-dbus/src/main.rs
Marco Allegretti 38be2c584d feat: karapace-dbus — socket-activated D-Bus service with 11 methods
- org.karapace.Manager1 D-Bus interface
- 11 methods: ListEnvironments, GetEnvironmentStatus, GetEnvironmentHash,
  BuildEnvironment, BuildNamedEnvironment, DestroyEnvironment, RunEnvironment,
  RenameEnvironment, ListPresets, GarbageCollect, VerifyStore
- Name-aware resolution (env_id, short_id, name, prefix)
- Desktop notifications via notify-rust (non-fatal if daemon unavailable)
- Typed serde response structs (no hand-rolled JSON)
- 30-second idle timeout for socket activation
- Hardened systemd unit: ProtectSystem=strict, ProtectHome=read-only,
  PrivateTmp, NoNewPrivileges
2026-02-22 18:38:09 +01:00

30 lines
918 B
Rust

use std::path::PathBuf;
use tracing::info;
fn default_store_path() -> PathBuf {
if let Ok(home) = std::env::var("HOME") {
PathBuf::from(home).join(".local/share/karapace")
} else {
PathBuf::from("/tmp/karapace")
}
}
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::try_from_env("KARAPACE_LOG")
.unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
)
.with_target(false)
.without_time()
.init();
let store_root =
std::env::var("KARAPACE_STORE").map_or_else(|_| default_store_path(), PathBuf::from);
info!("karapace-dbus starting, store: {}", store_root.display());
karapace_dbus::run_service(store_root.to_string_lossy().to_string()).await?;
Ok(())
}