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(
exec_chroot(
"grub-install",
vec![
String::from("--target=x86_64-efi"), String::from("--target=x86_64-efi"),
format!("--efi-directory={}", efidir), format!("--efi-directory={}", efidir),
String::from("--bootloader-id=crystal"), String::from("--bootloader-id=crystal"),
]), "install grub as efi"); ],
exec_eval(exec_chroot("grub-mkconfig", vec![ ),
String::from("-o"), "install grub as efi",
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",
);
} }
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(
exec(
"ln", "ln",
vec![ vec![
"-sf".to_string(), "-sf".to_string(),
format!("/usr/share/zoneinfo/{}", timezone), format!("/usr/share/zoneinfo/{}", timezone),
"/etc/localtime".to_string(), "/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(
files::append_file(
"/etc/vconsole.conf", "/etc/vconsole.conf",
format!("KEYMAP={}", keyboard).as_str(), format!("KEYMAP={}", keyboard).as_str(),
), "set keyboard layout"); ),
"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,7 +7,8 @@ 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(
exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -15,8 +16,11 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("mklabel"), String::from("mklabel"),
String::from("gpt"), String::from("gpt"),
], ],
), format!("create gpt label on {}", device).as_str()); ),
exec_eval(exec( format!("create gpt label on {}", device).as_str(),
);
exec_eval(
exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -26,8 +30,11 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("0"), String::from("0"),
String::from("300"), String::from("300"),
], ],
), "create EFI partition"); ),
exec_eval(exec( "create EFI partition",
);
exec_eval(
exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -37,9 +44,12 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("300"), String::from("300"),
String::from("100%"), String::from("100%"),
], ],
), "Create btrfs root partition"); ),
"Create btrfs root partition",
);
} else { } else {
exec_eval(exec( exec_eval(
exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -47,8 +57,11 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("mklabel"), String::from("mklabel"),
String::from("msdos"), String::from("msdos"),
], ],
), format!("Create msdos label on {}", device).as_str()); ),
exec_eval(exec( format!("Create msdos label on {}", device).as_str(),
);
exec_eval(
exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -58,8 +71,11 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("512MIB"), String::from("512MIB"),
String::from("100&"), String::from("100&"),
], ],
), "create btrfs root partition"); ),
exec_eval(exec( "create btrfs root partition",
);
exec_eval(
exec(
"parted", "parted",
vec![ vec![
String::from("-s"), String::from("-s"),
@ -69,7 +85,9 @@ pub fn partition(device: &str, mode: &str, efi: bool) {
String::from("1MIB"), String::from("1MIB"),
String::from("512MIB"), String::from("512MIB"),
], ],
), "create bios boot partition"); ),
"create bios boot partition",
);
} }
} }
if device.contains("nvme") { if device.contains("nvme") {
@ -81,10 +99,17 @@ 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(
exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -92,8 +117,11 @@ fn part_nvme(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@"), String::from("@"),
], ],
), "Create btrfs subvolume @"); ),
exec_eval(exec_workdir( "Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -101,19 +129,35 @@ fn part_nvme(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@home"), String::from("@home"),
], ],
), "Create btrfs subvolume @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(
exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -121,8 +165,11 @@ fn part_nvme(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@"), String::from("@"),
], ],
), "Create btrfs subvolume @"); ),
exec_eval(exec_workdir( "Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -130,22 +177,35 @@ fn part_nvme(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@home"), String::from("@home"),
], ],
), "Create btrfs subvolume @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(
exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -153,8 +213,11 @@ fn part_disk(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@"), String::from("@"),
], ],
), "Create btrfs subvolume @"); ),
exec_eval(exec_workdir( "Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -162,19 +225,31 @@ fn part_disk(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@home"), String::from("@home"),
], ],
), "Create btrfs subvolume @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(
exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -182,8 +257,11 @@ fn part_disk(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@"), String::from("@"),
], ],
), "Create btrfs subvolume @"); ),
exec_eval(exec_workdir( "Create btrfs subvolume @",
);
exec_eval(
exec_workdir(
"btrfs", "btrfs",
"/mnt", "/mnt",
vec![ vec![
@ -191,11 +269,19 @@ fn part_disk(device: &str, efi: bool) {
String::from("create"), String::from("create"),
String::from("@home"), String::from("@home"),
], ],
), "create btrfs subvolume @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,7 +289,8 @@ 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(
exec(
"mount", "mount",
vec![ vec![
String::from(partition), String::from(partition),
@ -211,9 +298,18 @@ fn mount(partition: &str, mountpoint: &str, options: &str) {
String::from("-o"), String::from("-o"),
String::from(options), 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,7 +2,8 @@ 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(
exec_chroot(
"useradd", "useradd",
vec![ vec![
String::from("-m"), String::from("-m"),
@ -10,9 +11,12 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
String::from("/bin/bash"), String::from("/bin/bash"),
String::from(username), 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", "usermod",
vec![ vec![
String::from("-a"), String::from("-a"),
@ -20,9 +24,12 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
String::from("wheel"), String::from("wheel"),
String::from(username), String::from(username),
], ],
), format!("Add user {} to wheel group", username).as_str()); ),
format!("Add user {} to wheel group", username).as_str(),
);
} }
exec_eval(exec_chroot( exec_eval(
exec_chroot(
"usermod", "usermod",
vec![ vec![
String::from("--password"), String::from("--password"),
@ -35,12 +42,15 @@ pub fn new_user(username: &str, hasroot: bool, password: &str) {
String::from("-stdin)"), String::from("-stdin)"),
String::from(username), String::from(username),
], ],
), format!("Set password for user {}", username).as_str()); ),
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(
exec_chroot(
"usermod", "usermod",
vec![ vec![
String::from("--password"), String::from("--password"),
@ -53,5 +63,7 @@ pub fn root_pass(root_pass: &str) {
String::from("-stdin)"), String::from("-stdin)"),
String::from("root"), 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