feat: bootstrap awg2 harness rust workspace and docs
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
mod cli;
|
||||
mod config;
|
||||
mod daemon;
|
||||
mod docker;
|
||||
mod error;
|
||||
mod firewall;
|
||||
mod iface;
|
||||
mod lock;
|
||||
mod netns;
|
||||
mod reboot;
|
||||
mod status;
|
||||
mod swap;
|
||||
mod traffic;
|
||||
mod wg;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
use crate::cli::{Cli, Command};
|
||||
use crate::config::Config;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let cli = Cli::parse();
|
||||
let config_path = cli
|
||||
.config
|
||||
.unwrap_or_else(|| PathBuf::from("/etc/awg2-harness/config.toml"));
|
||||
|
||||
match cli.command {
|
||||
Command::ValidateConfig => {
|
||||
let cfg = Config::load(&config_path)?;
|
||||
cfg.validate()?;
|
||||
println!("config valid: {}", config_path.display());
|
||||
}
|
||||
Command::ApplyLimits => {
|
||||
let cfg = Config::load(&config_path)?;
|
||||
cfg.validate()?;
|
||||
traffic::reconcile_traffic(&cfg)?;
|
||||
println!("traffic limits reconciled");
|
||||
}
|
||||
Command::ApplyFirewall => {
|
||||
let cfg = Config::load(&config_path)?;
|
||||
cfg.validate()?;
|
||||
firewall::apply_firewall(&cfg)?;
|
||||
println!("firewall reconciled");
|
||||
}
|
||||
Command::Status => {
|
||||
let cfg = Config::load(&config_path)?;
|
||||
cfg.validate()?;
|
||||
status::print_status(&cfg)?;
|
||||
}
|
||||
Command::EnsureSwap => {
|
||||
let cfg = Config::load(&config_path)?;
|
||||
cfg.validate()?;
|
||||
swap::ensure_swap(&cfg)?;
|
||||
println!("swap ensured");
|
||||
}
|
||||
Command::Daemon => {
|
||||
let cfg = Config::load(&config_path)?;
|
||||
cfg.validate()?;
|
||||
daemon::run(cfg)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user