SHA256
Compare commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
c7b57d0b68 | ||
|
|
0862b4f37f | ||
|
|
5583e52477 | ||
|
|
1fb8560381 |
No files matched your search
Generated
+1
-1
@@ -284,7 +284,7 @@ checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nyanit"
|
name = "nyanit"
|
||||||
version = "0.2.5"
|
version = "0.2.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix",
|
"nix",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nyanit"
|
name = "nyanit"
|
||||||
version = "0.2.5"
|
version = "0.2.8"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ workdir=$1
|
|||||||
|
|
||||||
echo "Populate initdramfs tree..."
|
echo "Populate initdramfs tree..."
|
||||||
cd $workdir
|
cd $workdir
|
||||||
mkdir -p initramfs/{dev,proc,sys,run,mnt,mnt/bee_root,tmp,etc,usr,usr/bin,usr/lib}
|
mkdir -p initramfs/{dev,proc,sys,run,mnt,mnt/bee-root,tmp,etc,usr,usr/bin,usr/lib}
|
||||||
|
|
||||||
echo "Create /bin /lib /lib64 simlinks"
|
echo "Create /bin /lib /lib64 simlinks"
|
||||||
cd $workdir/initramfs
|
cd $workdir/initramfs
|
||||||
|
|||||||
+9
-3
@@ -267,6 +267,7 @@ impl NyanitTUI<'_> {
|
|||||||
let mut tty_input_async = termion::async_stdin().keys();
|
let mut tty_input_async = termion::async_stdin().keys();
|
||||||
|
|
||||||
self.time_counter = 0;
|
self.time_counter = 0;
|
||||||
|
self.time_counter_sec = 0;
|
||||||
while !self.exit {
|
while !self.exit {
|
||||||
terminal.draw(|frame| self.draw(frame))?;
|
terminal.draw(|frame| self.draw(frame))?;
|
||||||
self.handle_events(&mut tty_input_async)?;
|
self.handle_events(&mut tty_input_async)?;
|
||||||
@@ -321,7 +322,7 @@ impl NyanitTUI<'_> {
|
|||||||
let f2_lines: Vec<Line> = vec![
|
let f2_lines: Vec<Line> = vec![
|
||||||
Line::from("Press F2 for options"),
|
Line::from("Press F2 for options"),
|
||||||
Line::default(),
|
Line::default(),
|
||||||
Line::from((WAIT_FOR_F2_SEC.saturating_sub(self.time_counter)).to_string()),
|
Line::from((WAIT_FOR_F2_SEC.saturating_sub(self.time_counter_sec)).to_string()),
|
||||||
];
|
];
|
||||||
|
|
||||||
let f2_paragraph = Paragraph::new(f2_lines).centered().magenta().bold();
|
let f2_paragraph = Paragraph::new(f2_lines).centered().magenta().bold();
|
||||||
@@ -411,8 +412,6 @@ impl NyanitTUI<'_> {
|
|||||||
ok_text,
|
ok_text,
|
||||||
vertical_chunks[1].centered_vertically(Constraint::Length(3)),
|
vertical_chunks[1].centered_vertically(Constraint::Length(3)),
|
||||||
);
|
);
|
||||||
// just some time to look at beez
|
|
||||||
thread::sleep(Duration::from_millis(1000))
|
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
@@ -540,6 +539,13 @@ impl NyanitTUI<'_> {
|
|||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
|
NyanitState::HandOff => {
|
||||||
|
// just some time to look at beez
|
||||||
|
thread::sleep(Duration::from_millis(1000));
|
||||||
|
if let Err(ex) = nyan_system::hand_off_control(TMP_ROOT, SYS_INIT) {
|
||||||
|
self.state = NyanitState::Error(ex.to_string())
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
-130
@@ -19,10 +19,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use nix;
|
use nix;
|
||||||
|
use regex_lite::Regex;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use regex_lite::Regex;
|
|
||||||
|
|
||||||
|
|
||||||
/// timeout for block deices population
|
/// timeout for block deices population
|
||||||
const WAIT_FOR_BLK_DEVS: u64 = 5u64;
|
const WAIT_FOR_BLK_DEVS: u64 = 5u64;
|
||||||
@@ -138,7 +137,6 @@ pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub struct BlkIdRes {
|
pub struct BlkIdRes {
|
||||||
pub fs_type: String,
|
pub fs_type: String,
|
||||||
@@ -149,8 +147,7 @@ impl BlkIdRes {
|
|||||||
pub fn is_bcachefs(&self) -> bool {
|
pub fn is_bcachefs(&self) -> bool {
|
||||||
if self.fs_type == "bcachefs" {
|
if self.fs_type == "bcachefs" {
|
||||||
true
|
true
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,17 +183,23 @@ pub fn find_partlabel(partlabel: &str) -> Result<Option<BlkIdRes>, ExecCommandEr
|
|||||||
])
|
])
|
||||||
.output()?;
|
.output()?;
|
||||||
if out.status.success() {
|
if out.status.success() {
|
||||||
let re = Regex::new(r#"^(/dev/[a-z0-9-]+): TYPE="([a-z]+)" PARTLABEL="[a-z0-9-]+"$"#)
|
let re =
|
||||||
.unwrap();
|
Regex::new(r#"^(/dev/[a-z0-9-]+): TYPE="([a-z]+)" PARTLABEL="[a-z0-9-]+""#).unwrap();
|
||||||
let out_text = String::from_utf8(out.stdout)?;
|
let out_text = String::from_utf8(out.stdout)?;
|
||||||
|
let out_text_trimmed = out_text.trim();
|
||||||
if let Some(captured) = re.captures(&out_text) {
|
if let Some(captured) = re.captures(out_text_trimmed) {
|
||||||
// let part_no = captured[1];
|
// let part_no = captured[1];
|
||||||
// let parent_dev = captured[2];
|
// let parent_dev = captured[2];
|
||||||
let res = BlkIdRes{ fs_type: captured[2].to_string(), dev_node: captured[1].to_string()};
|
let res = BlkIdRes {
|
||||||
|
fs_type: captured[2].to_string(),
|
||||||
|
dev_node: captured[1].to_string(),
|
||||||
|
};
|
||||||
Ok(Some(res))
|
Ok(Some(res))
|
||||||
} else {
|
} else {
|
||||||
Err(ExecCommandError::Other(format!("Unexpected blkid output format: \"{}\"", out_text)))
|
Err(ExecCommandError::Other(format!(
|
||||||
|
"Unexpected blkid output format: \"{}\"",
|
||||||
|
out_text
|
||||||
|
)))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(code) = out.status.code()
|
if let Some(code) = out.status.code()
|
||||||
@@ -512,125 +515,6 @@ impl Iterator for RollBackIterator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn roll_back_snap(
|
|
||||||
// snaps_list: Vec<String>,
|
|
||||||
// target_snap: String,
|
|
||||||
// ) -> impl Iterator<Item = Result<String, ExecCommandError>> {
|
|
||||||
// let usr_ro_snap_path = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", target_snap);
|
|
||||||
// let var_ro_snap_path = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", target_snap);
|
|
||||||
|
|
||||||
// let mut roll_state = RollbackStates::Start;
|
|
||||||
|
|
||||||
// std::iter::from_fn(move || match roll_state {
|
|
||||||
// RollbackStates::Start => {
|
|
||||||
// roll_state = RollbackStates::RenameUsrVarAct;
|
|
||||||
// Some(Ok("Move usr and var to temporary location".into()))
|
|
||||||
// }
|
|
||||||
// RollbackStates::RenameUsrVarAct => {
|
|
||||||
// let move_res = fs::rename(TMP_ROOT_USR, TMP_ROOT_SNAPS_USR)
|
|
||||||
// .and_then(|_| fs::rename(TMP_ROOT_VAR, TMP_ROOT_SNAPS_VAR));
|
|
||||||
// if let Err(ex) = move_res {
|
|
||||||
// roll_state = RollbackStates::Err;
|
|
||||||
// Some(Err(ex.into()))
|
|
||||||
// } else {
|
|
||||||
// roll_state = RollbackStates::ChangeToRw;
|
|
||||||
// Some(Ok("Setting snapshot as current system ...".into()))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// RollbackStates::ChangeToRw => {
|
|
||||||
// let rw_res = snapshot_rw(&usr_ro_snap_path, TMP_ROOT_USR)
|
|
||||||
// .and_then(|_| snapshot_rw(&var_ro_snap_path, TMP_ROOT_VAR));
|
|
||||||
// if let Err(ex) = rw_res {
|
|
||||||
// roll_state = RollbackStates::Err;
|
|
||||||
// Some(Err(ex))
|
|
||||||
// } else {
|
|
||||||
// roll_state = RollbackStates::MoveSubvolums;
|
|
||||||
// Some(Ok(
|
|
||||||
// "Moving subvolumes from old /usr and /var to new one".into()
|
|
||||||
// ))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// RollbackStates::MoveSubvolums => {
|
|
||||||
// let mut mv_res = Some(Ok("Removing old /usr and /var".into()));
|
|
||||||
// for (vol, svol_path) in SBUVOL_TO_MOVE {
|
|
||||||
// let v_from = format!("{}{}{}", TMP_ROOT_SNAPS_PREFIX, vol, svol_path);
|
|
||||||
// let v_dest = format!("{}/{}{}", TMP_ROOT, vol, svol_path);
|
|
||||||
// if let Err(ex) = fs::rename(v_from, v_dest) {
|
|
||||||
// roll_state = RollbackStates::Err;
|
|
||||||
// mv_res = Some(Err(ex.into()));
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// roll_state = RollbackStates::RemoveOldVols;
|
|
||||||
// mv_res
|
|
||||||
// }
|
|
||||||
// RollbackStates::RemoveOldVols => {
|
|
||||||
// let rem_old_res = subvolume_delete(TMP_ROOT_SNAPS_USR)
|
|
||||||
// .and_then(|_| subvolume_delete(TMP_ROOT_SNAPS_VAR));
|
|
||||||
// if let Err(ex) = rem_old_res {
|
|
||||||
// roll_state = RollbackStates::Err;
|
|
||||||
// Some(Err(ex))
|
|
||||||
// } else {
|
|
||||||
// roll_state = RollbackStates::ClearSnaps;
|
|
||||||
// Some(Ok("Clearing snapshots...".into()))
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// RollbackStates::ClearSnaps => {
|
|
||||||
// let mut clr_snap_res = Some(Ok("All done!".into()));
|
|
||||||
// for snap_date_time in snaps_list.iter().rev() {
|
|
||||||
// let usr_snap = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", snap_date_time);
|
|
||||||
// let var_snap = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "var", snap_date_time);
|
|
||||||
// if let Err(ex) =
|
|
||||||
// subvolume_delete(&usr_snap).and_then(|_| subvolume_delete(&var_snap))
|
|
||||||
// {
|
|
||||||
// clr_snap_res = Some(Err(ex));
|
|
||||||
// roll_state = RollbackStates::Err;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// if snap_date_time == &target_snap {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// clr_snap_res
|
|
||||||
// }
|
|
||||||
// RollbackStates::Finish => None,
|
|
||||||
// RollbackStates::Err => None,
|
|
||||||
// })
|
|
||||||
|
|
||||||
// // 1. Rename usr and var to TMP_ROOT_SNAPS/tmp_var|usr
|
|
||||||
// // fs::rename(TMP_ROOT_USR, TMP_ROOT_SNAPS_USR)?;
|
|
||||||
// // fs::rename(TMP_ROOT_VAR, TMP_ROOT_SNAPS_VAR)?;
|
|
||||||
|
|
||||||
// // 2. snapshot desired snaps as RW to /usr and /var
|
|
||||||
// // snapshot_rw(&usr_ro_snap_path, TMP_ROOT_USR)?;
|
|
||||||
// // snapshot_rw(&var_ro_snap_path, TMP_ROOT_VAR)?;
|
|
||||||
|
|
||||||
// // 3. move subvolumes from old /usr and /var
|
|
||||||
// // for (vol, svol_path) in SBUVOL_TO_MOVE {
|
|
||||||
// // let v_from = format!("{}{}{}", TMP_ROOT_SNAPS_PREFIX, vol, svol_path);
|
|
||||||
// // let v_dest = format!("{}/{}{}",TMP_ROOT,vol,svol_path);
|
|
||||||
// // fs::rename(v_from, v_dest)?;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // 4. removing tmp /usr /var
|
|
||||||
// // subvolume_delete(TMP_ROOT_SNAPS_USR)?;
|
|
||||||
// // subvolume_delete(TMP_ROOT_SNAPS_VAR)?;
|
|
||||||
|
|
||||||
// // 5. Removing all snapshoots made after one we restored, including inself
|
|
||||||
// // Iterate in reverse untill we get to target_snap in snaps list
|
|
||||||
// // for snap_date_time in snaps_list.iter().rev() {
|
|
||||||
// // let usr_snap = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", snap_date_time);
|
|
||||||
// // let var_snap = format!("{}/bzz-{}-{}", TMP_ROOT_SNAPS, "usr", snap_date_time);
|
|
||||||
// // subvolume_delete(&usr_snap)?;
|
|
||||||
// // subvolume_delete(&var_snap)?;
|
|
||||||
// // if snap_date_time == target_snap {
|
|
||||||
// // break;
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // Ok(())
|
|
||||||
// }
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Checks if pac_lock file exist and returns date-time from it if it does,
|
/// Checks if pac_lock file exist and returns date-time from it if it does,
|
||||||
/// Otherwise return None
|
/// Otherwise return None
|
||||||
|
|||||||
Reference in new issue
Block a user