1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- use easy_repl::{command, CommandStatus, Repl};
- use crate::{cfg};
- use crate::op::{makesure, once};
- pub fn prepare_view() {
- let repl_bresult = Repl::builder()
- .description("rumia-cli system view: /prepare")
- .prompt("[ rumia-cli: /prepare ] ")
- .add("checklist", command! {
- "print a checklist for prepare sequence",
- () => || {
- println!("Prepare Sequence:\n\
- sysfs-mount\n\
- proc-mount\n\
- bootfs-mount\n\
- cfg-phase2-load\n\
- initrd-env-load\n\
- run-mount-from-cfg\
- ");
- Ok(CommandStatus::Done)
- }
- })
- .add("bootfs-mount", command! {
- "mount /boot",
- () => || {
- makesure::mkdir_p("/boot");
- once::mount_bootfs();
- Ok(CommandStatus::Done)
- }
- })
- .add("cfg-phase2-load", command! {
- "load rumia config phase 2",
- () => || {
- cfg::load_phase2();
- Ok(CommandStatus::Done)
- }
- })
- .add("initrd-env-load", command! {
- "load rumia config phase 2",
- () => || {
- makesure::export_initrd_env_from_cfg();
- Ok(CommandStatus::Done)
- }
- })
- .add("env-load", command! {
- "load rumia config phase 2",
- () => || {
- makesure::export_env_from_cfg();
- Ok(CommandStatus::Done)
- }
- })
- .add("run-mount-cli", command! {
- "mount '/run' with given option",
- (option: String) => |option:String| {
- makesure::mkdir_p("/run");
- once::mount_runfs(option.as_str());
- makesure::mkdir_p_with_mode("/run/initramfs", 0o755);
- Ok(CommandStatus::Done)
- }
- })
- .add("run-mount-from-cfg", command! {
- "mount '/run' with config",
- () => || {
- makesure::mkdir_p("/run");
- once::mount_runfs_from_cfg();
- makesure::mkdir_p_with_mode("/run/initramfs", 0o755);
- Ok(CommandStatus::Done)
- }
- })
- .build();
- let mut repl = match repl_bresult {
- Ok(t) => t,
- Err(err) => {
- println!("[ERROR] fatal error when initializing this view: {:?}", err);
- return;
- }
- };
- let repl_run_result = repl.run();
- match repl_run_result {
- Ok(_) => {}
- Err(err) => {
- println!("[ERROR] this view crash by error: {:?}", err);
- println!("back to parent view...");
- }
- };
- }
|