made clippy shut up and ran cargo fmt

axtloss/rework-partitioning
amy 3 years ago
parent dce3a65210
commit 09573dd0b1

@ -25,12 +25,31 @@ jade partition auto /dev/sda --efi
jade partition auto /dev/nvmen0 jade partition auto /dev/nvmen0
``` ```
### install base packages
```sh
jade install-base
```
### install bootloader
```sh
# install as efi with esp being /boot/efi
jade bootloader grub-efi /boot/efi
# install as legacy on /dev/sda
jade bootloader grub-legacy /dev/sda
```
### configuring locale settings ### configuring locale settings
```sh ```sh
# set the keyboard layout to colemak, the timezone to Europe/Berlin and set en_US.UTF-8 as the locale # set the keyboard layout to colemak, the timezone to Europe/Berlin and set en_US.UTF-8 as the locale
jade locale colemak Europe/Berlin "en_US.UTF-8 UTF-8" jade locale colemak Europe/Berlin "en_US.UTF-8 UTF-8"
``` ```
### create /etc/hosts
```sh
jade networking --hosts
```
### configue network settings ### configue network settings
```sh ```sh
# set the hostname to getcryst.al with ipv6 disabled # set the hostname to getcryst.al with ipv6 disabled

@ -23,32 +23,42 @@ pub fn install_base_packages() {
]); ]);
} }
pub fn create_hosts() {
files::create_file("/mnt/etc/hosts");
files_eval(files::append_file("/mnt/etc/hosts", "127.0.0.1 localhost"), "create /etc/hosts");
}
pub fn install_bootloader_efi(efidir: &str) { pub fn install_bootloader_efi(efidir: &str) {
install::install(vec!["grub", "efibootmgr",]); install::install(vec!["grub", "efibootmgr"]);
exec_eval(exec_chroot("grub-install", vec![ exec_eval(
String::from("--target=x86_64-efi"), exec_chroot(
format!("--efi-directory={}", efidir), "grub-install",
String::from("--bootloader-id=crystal"), vec![
]), "install grub as efi"); String::from("--target=x86_64-efi"),
exec_eval(exec_chroot("grub-mkconfig", vec![ format!("--efi-directory={}", efidir),
String::from("-o"), String::from("--bootloader-id=crystal"),
String::from("/boot/grub/grub.cfg"), ],
]), "create grub.cfg"); ),
"install grub as efi",
);
exec_eval(
exec_chroot(
"grub-mkconfig",
vec![String::from("-o"), String::from("/boot/grub/grub.cfg")],
),
"create grub.cfg",
);
} }
pub fn install_bootloader_legacy(device: &str) { pub fn install_bootloader_legacy(device: &str) {
install::install(vec!["grub"]); install::install(vec!["grub"]);
exec_eval(exec_chroot("grub-install", vec![ exec_eval(
String::from("--target=i386-pc"), exec_chroot(
String::from(device), "grub-install",
]), "install grub as legacy"); vec![String::from("--target=i386-pc"), String::from(device)],
exec_eval(exec_chroot("grub-mkconfig", vec![ ),
String::from("-o"), "install grub as legacy",
String::from("/boot/grub/grub.cfg"), );
]), "create grub.cfg"); exec_eval(
exec_chroot(
"grub-mkconfig",
vec![String::from("-o"), String::from("/boot/grub/grub.cfg")],
),
"create grub.cfg",
);
} }

@ -2,29 +2,50 @@ use crate::internal::exec::*;
use crate::internal::*; use crate::internal::*;
pub fn set_timezone(timezone: &str) { pub fn set_timezone(timezone: &str) {
exec_eval(exec( exec_eval(
"ln", exec(
vec![ "ln",
"-sf".to_string(), vec![
format!("/usr/share/zoneinfo/{}", timezone), "-sf".to_string(),
"/etc/localtime".to_string(), format!("/usr/share/zoneinfo/{}", timezone),
], "/etc/localtime".to_string(),
), "Set timezone"); ],
exec_eval(exec_chroot("hwclock", vec!["--systohc".to_string()]), "Set system clock"); ),
"Set timezone",
);
exec_eval(
exec_chroot("hwclock", vec!["--systohc".to_string()]),
"Set system clock",
);
} }
pub fn set_locale(locale: String) { pub fn set_locale(locale: String) {
files_eval(files::append_file("/etc/locale.gen", "en_US.UTF-8 UTF-8"), "add en_US.UTF-8 UTF-8 to locale.gen"); files_eval(
files_eval(files::append_file("/etc/locale.gen", locale.as_str()), "add locales to locale.gen"); files::append_file("/etc/locale.gen", "en_US.UTF-8 UTF-8"),
exec_eval(exec_chroot("locale-gen", vec!["".to_string()]), "generate locales"); "add en_US.UTF-8 UTF-8 to locale.gen",
);
files_eval(
files::append_file("/etc/locale.gen", locale.as_str()),
"add locales to locale.gen",
);
exec_eval(
exec_chroot("locale-gen", vec!["".to_string()]),
"generate locales",
);
files::create_file("/etc/locale.conf"); files::create_file("/etc/locale.conf");
files_eval(files::append_file("/etc/locale.conf", "LANG=en_US.UTF-8"), "edit locale.conf"); files_eval(
files::append_file("/etc/locale.conf", "LANG=en_US.UTF-8"),
"edit locale.conf",
);
} }
pub fn set_keyboard(keyboard: &str) { pub fn set_keyboard(keyboard: &str) {
files::create_file("/etc/vconsole.conf"); files::create_file("/etc/vconsole.conf");
files_eval(files::append_file( files_eval(
"/etc/vconsole.conf", files::append_file(
format!("KEYMAP={}", keyboard).as_str(), "/etc/vconsole.conf",
), "set keyboard layout"); format!("KEYMAP={}", keyboard).as_str(),
),
"set keyboard layout",
);
} }

@ -1,6 +1,6 @@
pub mod base;
pub mod desktops; pub mod desktops;
pub mod locale; pub mod locale;
pub mod network; pub mod network;
pub mod partition; pub mod partition;
pub mod users; pub mod users;
pub mod base;

@ -3,14 +3,23 @@ use crate::internal::*;
pub fn set_hostname(hostname: &str) { pub fn set_hostname(hostname: &str) {
println!("Setting hostname to {}", hostname); println!("Setting hostname to {}", hostname);
files::create_file("/mnt/etc/hostname"); files::create_file("/mnt/etc/hostname");
files_eval(files::append_file("/mnt/etc/hostname", hostname), "set hostname"); files_eval(
files::append_file("/mnt/etc/hostname", hostname),
"set hostname",
);
} }
pub fn create_hosts() { pub fn create_hosts() {
files::create_file("/mnt/etc/hosts"); files::create_file("/mnt/etc/hosts");
files_eval(files::append_file("/mnt/etc/hosts", "127.0.0.1 localhost"), "create /etc/hosts"); files_eval(
files::append_file("/mnt/etc/hosts", "127.0.0.1 localhost"),
"create /etc/hosts",
);
} }
pub fn enable_ipv6() { pub fn enable_ipv6() {
files_eval(files::append_file("/mnt/etc/hosts", "::1 localhost"), "add ipv6 localhost"); files_eval(
files::append_file("/mnt/etc/hosts", "::1 localhost"),
"add ipv6 localhost",
);
} }

@ -7,69 +7,87 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
} else { } else {
log(format!("automatically partitioning {}", device)); log(format!("automatically partitioning {}", device));
if efi { if efi {
exec_eval(exec( exec_eval(
"parted", exec(
vec![ "parted",
String::from("-s"), vec![
String::from(device), String::from("-s"),
String::from("mklabel"), String::from(device),
String::from("gpt"), String::from("mklabel"),
], String::from("gpt"),
), format!("create gpt label on {}", device).as_str()); ],
exec_eval(exec( ),
"parted", format!("create gpt label on {}", device).as_str(),
vec![ );
String::from("-s"), exec_eval(
String::from(device), exec(
String::from("mkpart"), "parted",
String::from("fat32"), vec![
String::from("0"), String::from("-s"),
String::from("300"), String::from(device),
], String::from("mkpart"),
), "create EFI partition"); String::from("fat32"),
exec_eval(exec( String::from("0"),
"parted", String::from("300"),
vec![ ],
String::from("-s"), ),
String::from(device), "create EFI partition",
String::from("mkpart"), );
String::from("btrfs"), exec_eval(
String::from("300"), exec(
String::from("100%"), "parted",
], vec![
), "Create btrfs root partition"); String::from("-s"),
String::from(device),
String::from("mkpart"),
String::from("btrfs"),
String::from("300"),
String::from("100%"),
],
),
"Create btrfs root partition",
);
} else { } else {
exec_eval(exec( exec_eval(
"parted", exec(
vec![ "parted",
String::from("-s"), vec![
String::from(device), String::from("-s"),
String::from("mklabel"), String::from(device),
String::from("msdos"), String::from("mklabel"),
], String::from("msdos"),
), format!("Create msdos label on {}", device).as_str()); ],
exec_eval(exec( ),
"parted", format!("Create msdos label on {}", device).as_str(),
vec![ );
String::from("-s"), exec_eval(
String::from(device), exec(
String::from("mkpart"), "parted",
String::from("btrfs"), vec![
String::from("512MIB"), String::from("-s"),
String::from("100&"), String::from(device),
], String::from("mkpart"),
), "create btrfs root partition"); String::from("btrfs"),
exec_eval(exec( String::from("512MIB"),
"parted", String::from("100&"),
vec![ ],
String::from("-s"), ),
String::from(device), "create btrfs root partition",
String::from("mkpart"), );
String::from("ext4"), exec_eval(
String::from("1MIB"), exec(
String::from("512MIB"), "parted",
], vec![
), "create bios boot partition"); String::from("-s"),
String::from(device),
String::from("mkpart"),
String::from("ext4"),
String::from("1MIB"),
String::from("512MIB"),
],
),
"create bios boot partition",
);
} }
} }
if device.contains("nvme") { if device.contains("nvme") {
@ -81,121 +99,189 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
fn part_nvme(device: &str, efi: bool) { fn part_nvme(device: &str, efi: bool) {
if efi { if efi {
exec_eval(exec("mkfs.vfat", vec![format!("{}p1", device)]), format!("format {}p1 as fat32", device).as_str()); exec_eval(
exec_eval(exec("mkfs.btrfs", vec![format!("{}p2", device)]), format!("format {}p2 as btrfs", device).as_str()); exec("mkfs.vfat", vec![format!("{}p1", device)]),
format!("format {}p1 as fat32", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec![format!("{}p2", device)]),
format!("format {}p2 as btrfs", device).as_str(),
);
mount(format!("{}p2", device).as_str(), "/mnt", ""); mount(format!("{}p2", device).as_str(), "/mnt", "");
exec_eval(exec_workdir( exec_eval(
"btrfs", exec_workdir(
"/mnt", "btrfs",
vec![ "/mnt",
String::from("subvolume"), vec![
String::from("create"), String::from("subvolume"),
String::from("@"), String::from("create"),
], String::from("@"),
), "Create btrfs subvolume @"); ],
exec_eval(exec_workdir( ),
"btrfs", "Create btrfs subvolume @",
"/mnt", );
vec![ exec_eval(
String::from("subvolume"), exec_workdir(
String::from("create"), "btrfs",
String::from("@home"), "/mnt",
], vec![
), "Create btrfs subvolume @home"); String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"Create btrfs subvolume @home",
);
umount("/mnt"); umount("/mnt");
mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@"); mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot"); files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(files::create_directory("/mnt/boot/efi"), "create /mnt/boot/efi"); files_eval(
files::create_directory("/mnt/boot/efi"),
"create /mnt/boot/efi",
);
files_eval(files::create_directory("/mnt/home"), "create /mnt/home"); files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(format!("{}p2", device).as_str(), "/mnt/home", "subvol=@home"); mount(
format!("{}p2", device).as_str(),
"/mnt/home",
"subvol=@home",
);
mount(format!("{}p1", device).as_str(), "/mnt/boot/efi", ""); mount(format!("{}p1", device).as_str(), "/mnt/boot/efi", "");
} else { } else {
exec_eval(exec("mkfs.ext4", vec![format!("{}p1", device)]), format!("format {}p1 as ext4", device).as_str()); exec_eval(
exec_eval(exec("mkfs.btrfs", vec![format!("{}p2", device)]), format!("format {}p2 as btrfs", device).as_str()); exec("mkfs.ext4", vec![format!("{}p1", device)]),
format!("format {}p1 as ext4", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec![format!("{}p2", device)]),
format!("format {}p2 as btrfs", device).as_str(),
);
mount(format!("{}p2", device).as_str(), "/mnt/", ""); mount(format!("{}p2", device).as_str(), "/mnt/", "");
exec_eval(exec_workdir( exec_eval(
"btrfs", exec_workdir(
"/mnt", "btrfs",
vec![ "/mnt",
String::from("subvolume"), vec![
String::from("create"), String::from("subvolume"),
String::from("@"), String::from("create"),
], String::from("@"),
), "Create btrfs subvolume @"); ],
exec_eval(exec_workdir( ),
"btrfs", "Create btrfs subvolume @",
"/mnt", );
vec![ exec_eval(
String::from("subvolume"), exec_workdir(
String::from("create"), "btrfs",
String::from("@home"), "/mnt",
], vec![
), "Create btrfs subvolume @home"); String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"Create btrfs subvolume @home",
);
umount("/mnt"); umount("/mnt");
mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@"); mount(format!("{}p2", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot"); files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(files::create_directory("/mnt/home"), "create /mnt/home"); files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(format!("{}p2", device).as_str(), "/mnt/home", "subvol=@home"); mount(
format!("{}p2", device).as_str(),
"/mnt/home",
"subvol=@home",
);
mount(format!("{}p1", device).as_str(), "/mnt/boot", ""); mount(format!("{}p1", device).as_str(), "/mnt/boot", "");
} }
} }
fn part_disk(device: &str, efi: bool) { fn part_disk(device: &str, efi: bool) {
if efi { if efi {
exec_eval(exec("mkfs.vfat", vec![format!("{}1", device)]), format!("format {}1 as fat32", device).as_str()); exec_eval(
exec_eval(exec("mkfs.btrfs", vec![format!("{}2", device)]), format!("format {}2 as btrfs", device).as_str()); exec("mkfs.vfat", vec![format!("{}1", device)]),
format!("format {}1 as fat32", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec![format!("{}2", device)]),
format!("format {}2 as btrfs", device).as_str(),
);
mount(format!("{}2", device).as_str(), "/mnt", ""); mount(format!("{}2", device).as_str(), "/mnt", "");
exec_eval(exec_workdir( exec_eval(
"btrfs", exec_workdir(
"/mnt", "btrfs",
vec![ "/mnt",
String::from("subvolume"), vec![
String::from("create"), String::from("subvolume"),
String::from("@"), String::from("create"),
], String::from("@"),
), "Create btrfs subvolume @"); ],
exec_eval(exec_workdir( ),
"btrfs", "Create btrfs subvolume @",
"/mnt", );
vec![ exec_eval(
String::from("subvolume"), exec_workdir(
String::from("create"), "btrfs",
String::from("@home"), "/mnt",
], vec![
), "Create btrfs subvolume @home"); String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"Create btrfs subvolume @home",
);
umount("/mnt"); umount("/mnt");
mount(format!("{}2", device).as_str(), "/mnt/", "subvol=@"); mount(format!("{}2", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot"); files_eval(files::create_directory("/mnt/boot"), "create /mnt/boot");
files_eval(files::create_directory("/mnt/boot/efi"), "create /mnt/boot/efi"); files_eval(
files::create_directory("/mnt/boot/efi"),
"create /mnt/boot/efi",
);
files_eval(files::create_directory("/mnt/home"), "create /mnt/home"); files_eval(files::create_directory("/mnt/home"), "create /mnt/home");
mount(format!("{}2", device).as_str(), "/mnt/home", "subvol=@home"); mount(format!("{}2", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}1", device).as_str(), "/mnt/boot/efi", ""); mount(format!("{}1", device).as_str(), "/mnt/boot/efi", "");
} else { } else {
exec_eval(exec("mkfs.ext4", vec![format!("{}1", device)]), format!("format {}1 as ext4", device).as_str()); exec_eval(
exec_eval(exec("mkfs.btrfs", vec![format!("{}2", device)]), format!("format {}2 as btrfs", device).as_str()); exec("mkfs.ext4", vec![format!("{}1", device)]),
format!("format {}1 as ext4", device).as_str(),
);
exec_eval(
exec("mkfs.btrfs", vec![format!("{}2", device)]),
format!("format {}2 as btrfs", device).as_str(),
);
mount(format!("{}2", device).as_str(), "/mnt/", ""); mount(format!("{}2", device).as_str(), "/mnt/", "");
exec_eval(exec_workdir( exec_eval(
"btrfs", exec_workdir(
"/mnt", "btrfs",
vec![ "/mnt",
String::from("subvolume"), vec![
String::from("create"), String::from("subvolume"),
String::from("@"), String::from("create"),
], String::from("@"),
), "Create btrfs subvolume @"); ],
exec_eval(exec_workdir( ),
"btrfs", "Create btrfs subvolume @",
"/mnt", );
vec![ exec_eval(
String::from("subvolume"), exec_workdir(
String::from("create"), "btrfs",
String::from("@home"), "/mnt",
], vec![
), "create btrfs subvolume @home"); String::from("subvolume"),
String::from("create"),
String::from("@home"),
],
),
"create btrfs subvolume @home",
);
umount("/mnt"); umount("/mnt");
mount(format!("{}2", device).as_str(), "/mnt/", "subvol=@"); mount(format!("{}2", device).as_str(), "/mnt/", "subvol=@");
files_eval(files::create_directory("/mnt/boot"), "create directory /mnt/boot"); files_eval(
files_eval(files::create_directory("/mnt/home"), "create directory /mnt/home"); files::create_directory("/mnt/boot"),
"create directory /mnt/boot",
);
files_eval(
files::create_directory("/mnt/home"),
"create directory /mnt/home",
);
mount(format!("{}2", device).as_str(), "/mnt/home", "subvol=@home"); mount(format!("{}2", device).as_str(), "/mnt/home", "subvol=@home");
mount(format!("{}1", device).as_str(), "/mnt/boot", ""); mount(format!("{}1", device).as_str(), "/mnt/boot", "");
} }
@ -203,17 +289,27 @@ fn part_disk(device: &str, efi: bool) {
fn mount(partition: &str, mountpoint: &str, options: &str) { fn mount(partition: &str, mountpoint: &str, options: &str) {
let options = if options.is_empty() { "\"\"" } else { options }; let options = if options.is_empty() { "\"\"" } else { options };
exec_eval(exec( exec_eval(
"mount", exec(
vec![ "mount",
String::from(partition), vec![
String::from(mountpoint), String::from(partition),
String::from("-o"), String::from(mountpoint),
String::from(options), String::from("-o"),
], String::from(options),
), format!("mount {} with options {} at {}", partition, options, mountpoint).as_str()); ],
),
format!(
"mount {} with options {} at {}",
partition, options, mountpoint
)
.as_str(),
);
} }
fn umount(mountpoint: &str) { fn umount(mountpoint: &str) {
exec_eval(exec("umount", vec![String::from(mountpoint)]), format!("unmount {}", mountpoint).as_str()); exec_eval(
exec("umount", vec![String::from(mountpoint)]),
format!("unmount {}", mountpoint).as_str(),
);
} }

@ -2,56 +2,68 @@ use crate::internal::exec::*;
use crate::internal::*; use crate::internal::*;
pub fn new_user(username: &str, hasroot: bool, password: &str) { pub fn new_user(username: &str, hasroot: bool, password: &str) {
exec_eval(exec_chroot( exec_eval(
"useradd", exec_chroot(
vec![ "useradd",
String::from("-m"), vec![
String::from("-s"), String::from("-m"),
String::from("/bin/bash"), String::from("-s"),
String::from(username), String::from("/bin/bash"),
], String::from(username),
), format!("Create user {}", username).as_str()); ],
),
format!("Create user {}", username).as_str(),
);
if hasroot { if hasroot {
exec_eval(exec_chroot( exec_eval(
exec_chroot(
"usermod",
vec![
String::from("-a"),
String::from("-G"),
String::from("wheel"),
String::from(username),
],
),
format!("Add user {} to wheel group", username).as_str(),
);
}
exec_eval(
exec_chroot(
"usermod", "usermod",
vec![ vec![
String::from("-a"), String::from("--password"),
String::from("-G"), String::from("$(echo"),
String::from("wheel"), format!("${}", password),
String::from("|"),
String::from("openssl"),
String::from("passwd"),
String::from("-1"),
String::from("-stdin)"),
String::from(username), String::from(username),
], ],
), format!("Add user {} to wheel group", username).as_str()); ),
} format!("Set password for user {}", username).as_str(),
exec_eval(exec_chroot( );
"usermod",
vec![
String::from("--password"),
String::from("$(echo"),
format!("${}", password),
String::from("|"),
String::from("openssl"),
String::from("passwd"),
String::from("-1"),
String::from("-stdin)"),
String::from(username),
],
), format!("Set password for user {}", username).as_str());
} }
pub fn root_pass(root_pass: &str) { pub fn root_pass(root_pass: &str) {
println!("Setting root password to '{}'", root_pass); println!("Setting root password to '{}'", root_pass);
exec_eval(exec_chroot( exec_eval(
"usermod", exec_chroot(
vec![ "usermod",
String::from("--password"), vec![
String::from("$(echo"), String::from("--password"),
format!("${{{}}}", root_pass), String::from("$(echo"),
String::from("|"), format!("${{{}}}", root_pass),
String::from("openssl"), String::from("|"),
String::from("passwd"), String::from("openssl"),
String::from("-1"), String::from("passwd"),
String::from("-stdin)"), String::from("-1"),
String::from("root"), String::from("-stdin)"),
], String::from("root"),
), "set root password"); ],
),
"set root password",
);
} }

@ -7,7 +7,7 @@ pub fn exec(command: &str, args: Vec<String>) -> Result<std::process::ExitStatus
pub fn exec_chroot( pub fn exec_chroot(
command: &str, command: &str,
args: Vec<String> args: Vec<String>,
) -> Result<std::process::ExitStatus, std::io::Error> { ) -> Result<std::process::ExitStatus, std::io::Error> {
let returncode = Command::new("arch-chroot") let returncode = Command::new("arch-chroot")
.args(&["/mnt", command]) .args(&["/mnt", command])

@ -1,8 +1,8 @@
pub mod exec; pub mod exec;
pub mod files; pub mod files;
pub mod install; pub mod install;
pub mod strings;
pub mod returncode_eval; pub mod returncode_eval;
pub mod strings;
pub fn install(pkgs: Vec<&str>) { pub fn install(pkgs: Vec<&str>) {
install::install(pkgs); install::install(pkgs);
@ -20,7 +20,10 @@ pub fn files_eval(returncode: std::result::Result<(), std::io::Error>, logmsg: &
returncode_eval::files_eval(returncode, logmsg); returncode_eval::files_eval(returncode, logmsg);
} }
pub fn exec_eval(returncode: std::result::Result<std::process::ExitStatus, std::io::Error>, logmsg: &str) { pub fn exec_eval(
returncode: std::result::Result<std::process::ExitStatus, std::io::Error>,
logmsg: &str,
) {
returncode_eval::exec_eval(returncode, logmsg); returncode_eval::exec_eval(returncode, logmsg);
} }

@ -1,12 +1,18 @@
use crate::internal::*; use crate::internal::*;
pub fn exec_eval(return_code: std::result::Result<std::process::ExitStatus, std::io::Error>, logmsg: &str) { pub fn exec_eval(
return_code: std::result::Result<std::process::ExitStatus, std::io::Error>,
logmsg: &str,
) {
match &return_code { match &return_code {
Ok(_) => { Ok(_) => {
log(format!("{}: Success", logmsg)); log(format!("{}: Success", logmsg));
} }
Err(e) => { Err(e) => {
crash(format!("{}: Failed with error: {}", logmsg, e), return_code.unwrap_err().raw_os_error().unwrap()); crash(
format!("{}: Failed with error: {}", logmsg, e),
return_code.unwrap_err().raw_os_error().unwrap(),
);
} }
} }
} }
@ -17,7 +23,10 @@ pub fn files_eval(return_code: std::result::Result<(), std::io::Error>, logmsg:
log(format!("[ \x1b[2;1;32mOK\x1b[0m ] {}", logmsg)); log(format!("[ \x1b[2;1;32mOK\x1b[0m ] {}", logmsg));
} }
Err(e) => { Err(e) => {
crash(format!("[ \x1b[2;1;31mFAILED\x1b[0m ] {} ERROR: {}", logmsg, e), return_code.unwrap_err().raw_os_error().unwrap()); crash(
format!("[ \x1b[2;1;31mFAILED\x1b[0m ] {} ERROR: {}", logmsg, e),
return_code.unwrap_err().raw_os_error().unwrap(),
);
} }
} }
} }

@ -96,7 +96,6 @@ fn main() {
.help("Wether ipv6 should be enabled") .help("Wether ipv6 should be enabled")
.short("i6") .short("i6")
.long("ipv6") .long("ipv6")
.required(true)
.takes_value(false), .takes_value(false),
), ),
) )
@ -161,8 +160,12 @@ fn main() {
locale::set_keyboard(kbrlayout); locale::set_keyboard(kbrlayout);
locale::set_timezone(timezn); locale::set_timezone(timezn);
} else if let Some(app) = app.subcommand_matches("networking") { } else if let Some(app) = app.subcommand_matches("networking") {
if app.is_present("ipv6") { network::enable_ipv6() } if app.is_present("ipv6") {
if app.is_present("create-hosts") { network::create_hosts() } network::enable_ipv6()
}
if app.is_present("create-hosts") {
network::create_hosts()
}
network::set_hostname(app.value_of("hostname").unwrap()) network::set_hostname(app.value_of("hostname").unwrap())
} else if let Some(app) = app.subcommand_matches("users") { } else if let Some(app) = app.subcommand_matches("users") {
if let Some(app) = app.subcommand_matches("newUser") { if let Some(app) = app.subcommand_matches("newUser") {
@ -184,7 +187,7 @@ fn main() {
} else if let Some(app) = app.subcommand_matches("grub-legacy") { } else if let Some(app) = app.subcommand_matches("grub-legacy") {
base::install_bootloader_legacy(app.value_of("device").unwrap()); base::install_bootloader_legacy(app.value_of("device").unwrap());
} }
} else if let Some(_) = app.subcommand_matches("install-base") { } else if app.subcommand_matches("install-base").is_some() {
base::install_base_packages(); base::install_base_packages();
} else { } else {
println!("Running TUI installer"); println!("Running TUI installer");

Loading…
Cancel
Save