features
This commit is contained in:
parent
31110447da
commit
5f56b7fb77
23 changed files with 555 additions and 352 deletions
119
src/main.rs
119
src/main.rs
|
@ -1,4 +1,12 @@
|
|||
use navinstall::config::InstallConfig;
|
||||
use navinstall::fx::bluetooth::setup_bluetooth;
|
||||
use navinstall::fx::docker::setup_docker;
|
||||
use navinstall::fx::firewall::setup_firewall;
|
||||
use navinstall::fx::gpu::setup_video_drivers;
|
||||
use navinstall::fx::ollama::setup_ollama;
|
||||
use navinstall::fx::ssh::setup_ssh;
|
||||
use navinstall::fx::virt::{setup_virtualization, setup_vm_guest};
|
||||
use navinstall::fx::zram::setup_zram;
|
||||
use navinstall::install::navos::setup_navos;
|
||||
use navinstall::install::{
|
||||
drives::setup_disk_image, install, install_mnt, security::ensure_secure_boot,
|
||||
|
@ -24,69 +32,40 @@ fn main() {
|
|||
.paint(Color::Yellow)
|
||||
);
|
||||
|
||||
let args = navinstall::args::get_args();
|
||||
let args: navinstall::args::NavinstallArgs = argh::from_env();
|
||||
|
||||
match args.subcommand() {
|
||||
Some(("create-iso", iso_args)) => {
|
||||
let without_gui = iso_args.get_flag("without_gui");
|
||||
let no_tmp = iso_args.get_flag("no_tmp");
|
||||
match args.cmd {
|
||||
navinstall::args::NavinstallCommands::CreateISO(create_isocommand) => {
|
||||
let kb_layout_default = "us".to_string();
|
||||
let kb_layout: &String = iso_args.get_one("kb_layout").unwrap_or(&kb_layout_default);
|
||||
let kb_variant: Option<&str> =
|
||||
iso_args.get_one("kb_variant").map(|x: &String| x.as_str());
|
||||
let auto_install_config: Option<&String> = iso_args.get_one("install");
|
||||
let kb_layout = create_isocommand.kb_layout.unwrap_or(kb_layout_default);
|
||||
|
||||
let user: Option<&String> = iso_args.get_one("user");
|
||||
let pass: Option<&String> = iso_args.get_one("pass");
|
||||
let uid: Option<&String> = iso_args.get_one("uid");
|
||||
|
||||
let user = if user.is_some() && pass.is_some() {
|
||||
let user = if create_isocommand.user.is_some() && create_isocommand.pass.is_some() {
|
||||
Some((
|
||||
user.unwrap().to_string(),
|
||||
pass.unwrap().to_string(),
|
||||
uid.map(|x| x.parse().unwrap()).unwrap_or(1000),
|
||||
create_isocommand.user.unwrap().to_string(),
|
||||
create_isocommand.pass.unwrap().to_string(),
|
||||
create_isocommand.uid.unwrap_or(1000),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let units: Vec<_> = iso_args.get_many("unit").unwrap_or_default().collect();
|
||||
|
||||
create_iso(
|
||||
without_gui,
|
||||
no_tmp,
|
||||
kb_layout,
|
||||
kb_variant,
|
||||
create_isocommand.without_gui,
|
||||
create_isocommand.no_tmp,
|
||||
&kb_layout,
|
||||
create_isocommand.kb_variant,
|
||||
user,
|
||||
units.into_iter().map(|x: &String| x.to_string()).collect(),
|
||||
auto_install_config,
|
||||
create_isocommand.unit,
|
||||
create_isocommand.install,
|
||||
);
|
||||
std::process::exit(0);
|
||||
}
|
||||
Some(("create-tar", tar_options)) => {
|
||||
ensure_root();
|
||||
let dir: &String = tar_options.get_one("dir").unwrap();
|
||||
print_status("Pacstrapping root fs");
|
||||
pacstrap_at(&dir, &[]);
|
||||
setup_navos(dir.as_str());
|
||||
}
|
||||
Some(("create-img", install_args)) => {
|
||||
let config_file: &String = install_args.get_one("config").unwrap();
|
||||
let conf = read_conf(config_file);
|
||||
let img_file: &String = install_args.get_one("image").unwrap();
|
||||
let gpt = install_args.get_flag("gpt");
|
||||
|
||||
setup_disk_image(img_file.as_str(), gpt);
|
||||
install_mnt(conf, false);
|
||||
}
|
||||
Some(("install", install_args)) => {
|
||||
navinstall::args::NavinstallCommands::Install(install_command) => {
|
||||
ensure_root();
|
||||
|
||||
let config_file: &String = install_args.get_one("config").unwrap();
|
||||
let force = install_args.get_flag("force");
|
||||
let conf = read_conf(config_file);
|
||||
let conf = read_conf(&install_command.config);
|
||||
|
||||
if !force {
|
||||
if !install_command.force {
|
||||
print_config(&conf);
|
||||
print!("Do you want to proceed with this configuration? (yes/no) ");
|
||||
expect_yes();
|
||||
|
@ -99,7 +78,53 @@ fn main() {
|
|||
// Run the
|
||||
install(conf, true);
|
||||
}
|
||||
_ => {}
|
||||
navinstall::args::NavinstallCommands::CreateTar(create_tar_command) => {
|
||||
ensure_root();
|
||||
print_status("Pacstrapping root fs");
|
||||
pacstrap_at(&create_tar_command.dir, &[]);
|
||||
setup_navos(&create_tar_command.dir.as_str());
|
||||
}
|
||||
navinstall::args::NavinstallCommands::CreateImage(create_image_command) => {
|
||||
let conf = read_conf(&create_image_command.config);
|
||||
setup_disk_image(
|
||||
&create_image_command.image.as_str(),
|
||||
create_image_command.gpt,
|
||||
);
|
||||
install_mnt(conf, false);
|
||||
}
|
||||
navinstall::args::NavinstallCommands::Feature(feature_command) => {
|
||||
match feature_command.cmd {
|
||||
navinstall::fx::Features::Bluetooth(_) => setup_bluetooth(),
|
||||
navinstall::fx::Features::GPU(gpufeature) => {
|
||||
let vendor = match gpufeature.vendor.to_lowercase().as_str() {
|
||||
"amd" => navinstall::config::GPUVendor::AMD,
|
||||
"intel" => navinstall::config::GPUVendor::INTEL,
|
||||
"nvidia" => navinstall::config::GPUVendor::NVIDIA,
|
||||
_ => {
|
||||
println!("{} is no GPU vendor", gpufeature.vendor);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
setup_video_drivers(&vendor);
|
||||
}
|
||||
navinstall::fx::Features::Docker(docker_feature) => {
|
||||
setup_docker(&docker_feature.user);
|
||||
}
|
||||
navinstall::fx::Features::Firewall(firewall_feature) => {
|
||||
setup_firewall(firewall_feature.ssh)
|
||||
}
|
||||
navinstall::fx::Features::Ollama(ollama_feature) => {
|
||||
setup_ollama(&ollama_feature.into_config())
|
||||
}
|
||||
navinstall::fx::Features::SSH(sshfeature) => {
|
||||
setup_ssh(&Some(sshfeature.into_config()))
|
||||
}
|
||||
navinstall::fx::Features::Virt(virt_feature) => setup_virtualization(&virt_feature),
|
||||
navinstall::fx::Features::VirtGuest(_) => setup_vm_guest(),
|
||||
navinstall::fx::Features::Zram(_) => setup_zram(),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue