mod cli_tools;
mod dns_resolver;
mod docker_socket;
pub use cli_tools::CliTools;
pub use dns_resolver::DnsResolver;
pub use docker_socket::DockerSocket;
use arcbox_helper::client::{Client, ClientError};
#[async_trait::async_trait]
pub trait SetupTask: Send + Sync {
fn name(&self) -> &'static str;
fn is_satisfied(&self) -> bool;
async fn apply(&self, client: &Client) -> Result<(), ClientError>;
}
pub async fn run(tasks: &[&dyn SetupTask]) {
let client = match Client::connect().await {
Ok(c) => c,
Err(e) => {
tracing::debug!(
error = %e,
"arcbox-helper not reachable, skipping self-setup"
);
return;
}
};
for task in tasks {
let name = task.name();
if task.is_satisfied() {
tracing::debug!(task = name, "already satisfied");
continue;
}
match task.apply(&client).await {
Ok(()) => tracing::info!(task = name, "configured"),
Err(e) => tracing::warn!(
task = name,
error = %e,
"failed (run 'sudo arcbox install' to fix)"
),
}
}
}