2024-04-29 10:54:25 +00:00
|
|
|
mod bootstrap;
|
2024-05-14 22:59:57 +00:00
|
|
|
mod lsblk;
|
|
|
|
mod lvm;
|
2024-04-29 10:54:25 +00:00
|
|
|
|
2024-05-14 22:59:57 +00:00
|
|
|
use log::error;
|
|
|
|
|
|
|
|
use std::io::{self, Read, Write};
|
|
|
|
use std::process::exit;
|
|
|
|
use std::{env, fs};
|
2024-04-29 10:54:25 +00:00
|
|
|
|
|
|
|
fn main() {
|
2024-05-14 22:59:57 +00:00
|
|
|
if let None = env::var_os("RUST_LOG") {
|
|
|
|
env::set_var("RUST_LOG", "info");
|
|
|
|
}
|
|
|
|
env_logger::init();
|
|
|
|
|
|
|
|
if let Some(arg) = env::args().into_iter().nth(1) {
|
|
|
|
match arg.as_str() {
|
|
|
|
"hello" => println!("hello"),
|
|
|
|
_ => {
|
|
|
|
error!("invalid arg: {arg}");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
let Ok(cfg) =
|
|
|
|
fs::File::open("config.yaml").inspect_err(|e| error!("failed to read config: {e}"))
|
|
|
|
else {
|
|
|
|
exit(1);
|
|
|
|
};
|
2024-04-29 10:54:25 +00:00
|
|
|
|
2024-05-14 22:59:57 +00:00
|
|
|
let Ok(cfg) = serde_yaml::from_reader::<_, bootstrap::config::Config>(cfg)
|
|
|
|
.inspect_err(|e| error!("failed to parse config: {e}"))
|
|
|
|
else {
|
|
|
|
exit(1);
|
|
|
|
};
|
2024-04-29 10:54:25 +00:00
|
|
|
|
|
|
|
serde_yaml::to_writer(io::stdout(), &cfg).unwrap();
|
2024-05-14 22:59:57 +00:00
|
|
|
|
|
|
|
for pv in lvm::pvs().unwrap() {
|
|
|
|
println!("pv: {pv:?}");
|
|
|
|
}
|
|
|
|
for vg in lvm::vgs().unwrap() {
|
|
|
|
println!("vg: {vg:?}");
|
|
|
|
}
|
|
|
|
for lv in lvm::lvs().unwrap() {
|
|
|
|
println!("lv: {lv:?}");
|
|
|
|
}
|
|
|
|
|
|
|
|
println!("lsblk: {:?}", lsblk::report());
|
|
|
|
|
|
|
|
// TODO
|
2024-04-29 10:54:25 +00:00
|
|
|
}
|