start working on unakite
parent
1b05b6d203
commit
c47f47789c
@ -0,0 +1,142 @@
|
||||
use crate::internal::exec::*;
|
||||
use crate::internal::*;
|
||||
|
||||
pub fn install_bootloader_efi(efidir: PathBuf) {
|
||||
install::install(vec!["grub", "efibootmgr", "grub-btrfs", "crystal-grub-theme"]);
|
||||
let efidir = std::path::Path::new("/mnt").join(efidir);
|
||||
let efi_str = efidir.to_str().unwrap();
|
||||
if !std::path::Path::new(&format!("/mnt{efi_str}")).exists() {
|
||||
crash(format!("The efidir {efidir:?} doesn't exist"), 1);
|
||||
}
|
||||
exec_eval(
|
||||
exec_chroot(
|
||||
"grub-install",
|
||||
vec![
|
||||
String::from("--target=x86_64-efi"),
|
||||
format!("--efi-directory={}" , efi_str),
|
||||
String::from("--bootloader-id=unakite"),
|
||||
String::from("--removable"),
|
||||
],
|
||||
),
|
||||
"install unakite grub as efi with --removable",
|
||||
);
|
||||
exec_eval(
|
||||
exec_chroot(
|
||||
"grub-install",
|
||||
vec![
|
||||
String::from("--target=x86_64-efi"),
|
||||
format!("--efi-directory={}", efi_str),
|
||||
String::from("--bootloader-id=unakite"),
|
||||
],
|
||||
),
|
||||
"install unakite grub as efi without --removable",
|
||||
);
|
||||
files_eval(
|
||||
append_file("/mnt/etc/default/grub", "GRUB_THEME=\"/usr/share/grub/themes/crystal/theme.txt\""),
|
||||
"enable crystal grub theme"
|
||||
);
|
||||
exec_eval(
|
||||
exec_chroot(
|
||||
"grub-mkconfig",
|
||||
vec![String::from("-o"), String::from("/boot/grub/grub.cfg")],
|
||||
),
|
||||
"create grub.cfg",
|
||||
);
|
||||
}
|
||||
|
||||
pub fn remount(root: &str, oldroot: &stre, efi: bool, efidir: &str, bootdev: &str, firstrun: bool) {
|
||||
if efi && firstrun {
|
||||
exec_eval(
|
||||
exec(
|
||||
"umount",
|
||||
vec![String::from(bootdev)],
|
||||
),
|
||||
format!("Unmount {}", bootdev),
|
||||
)
|
||||
exec_eval(
|
||||
exec(
|
||||
"umount",
|
||||
vec![String::from("/")],
|
||||
),
|
||||
format!("Unmount old root"),
|
||||
);
|
||||
mount(root, "/");
|
||||
mount(bootdev, efidir);
|
||||
} else if efi && !firstrun {
|
||||
exec_eval(
|
||||
exec(
|
||||
"umount",
|
||||
vec![String::from(bootdev)],
|
||||
),
|
||||
format!("Unmount {}", bootdev),
|
||||
)
|
||||
exec_eval(
|
||||
exec(
|
||||
"umount",
|
||||
vec![String::from("/")],
|
||||
),
|
||||
format!("Unmount unakite root"),
|
||||
);
|
||||
mount(root, "/");
|
||||
mount(bootdev, efidir);
|
||||
} else if !efi && firstrun {
|
||||
exec_eval(
|
||||
exec(
|
||||
"umount",
|
||||
vec![String::from(bootdev)],
|
||||
),
|
||||
format!("Unmount {}", bootdev),
|
||||
)
|
||||
exec_eval(
|
||||
exec(
|
||||
"umount",
|
||||
vec![String::from("/")],
|
||||
),
|
||||
format!("Unmount old root"),
|
||||
);
|
||||
mount(root, "/");
|
||||
mount(bootdev, "/boot");
|
||||
} else if !efi && !firstrun {
|
||||
exec_eval(
|
||||
exec(
|
||||
"umount",
|
||||
vec![String::from(bootdev)],
|
||||
),
|
||||
format!("Unmount {}", bootdev),
|
||||
);
|
||||
exec_eval(
|
||||
exec(
|
||||
"umount",
|
||||
vec![String::from("/")],
|
||||
),
|
||||
format!("Unmount unakite root"),
|
||||
);
|
||||
mount(oldroot, "/");
|
||||
mount(bootdev, "/boot");
|
||||
} else {
|
||||
panic!("Unknown state");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup_unakite(root: &str, oldroot: &stre, efi: bool, efidir: &str, bootdev: &str) {
|
||||
log::debug!("Setting up Unakite");
|
||||
remount_efi(root, oldroot, efi, efidir, bootdev, true);
|
||||
base::install_base_packages();
|
||||
base::genfstab();
|
||||
if efi {
|
||||
install_bootloader_efi(PathBuf::from(efidir));
|
||||
}
|
||||
locale::set_locale("");
|
||||
locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone
|
||||
network::set_hostname("unakite");
|
||||
network::create_hosts("");
|
||||
users::new_user(
|
||||
"unakite",
|
||||
true,
|
||||
"Cp7oN04ZY0PsA", // unakite
|
||||
)
|
||||
users::root_pass("Cp7oN04ZY0PsA"); // unakite
|
||||
desktops::install_desktop_desktup_setup(DesktopSetup::Xfce);
|
||||
install(vec!["gparted", "firefox"]);
|
||||
remount(root, oldroot, efi, efidir, bootdev, false);
|
||||
}
|
Loading…
Reference in New Issue