3 Commits
5 changed files with 26 additions and 53 deletions
Generated
+4 -42
View File
@@ -2,15 +2,6 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 4 version = 4
[[package]]
name = "aho-corasick"
version = "1.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "allocator-api2" name = "allocator-api2"
version = "0.2.21" version = "0.2.21"
@@ -249,12 +240,6 @@ dependencies = [
"hashbrown 0.17.1", "hashbrown 0.17.1",
] ]
[[package]]
name = "memchr"
version = "2.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.31.3" version = "0.31.3"
@@ -304,7 +289,7 @@ dependencies = [
"nix", "nix",
"ratatui", "ratatui",
"ratatui-textarea", "ratatui-textarea",
"regex", "regex-lite",
"termion", "termion",
] ]
@@ -450,33 +435,10 @@ dependencies = [
] ]
[[package]] [[package]]
name = "regex" name = "regex-lite"
version = "1.13.1" version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" checksum = "cab834c73d247e67f4fae452806d17d3c7501756d98c8808d7c9c7aa7d18f973"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
[[package]] [[package]]
name = "rustversion" name = "rustversion"
+2 -2
View File
@@ -7,7 +7,7 @@ edition = "2024"
nix = { version = "0.31", features = ["mount"] } nix = { version = "0.31", features = ["mount"] }
ratatui = { version = "0.30", default-features = false, features = ["termion"] } ratatui = { version = "0.30", default-features = false, features = ["termion"] }
ratatui-textarea = { version = "0.9", default-features = false, features = ["termion"] } ratatui-textarea = { version = "0.9", default-features = false, features = ["termion"] }
regex = "1" regex-lite = "0.1"
termion = "4" termion = "4"
[profile.release] [profile.release]
@@ -15,5 +15,5 @@ lto = true
debug = false debug = false
incremental = false incremental = false
codegen-units = 1 codegen-units = 1
opt-level = 2 opt-level = "s"
strip = true strip = true
+13 -4
View File
@@ -8,14 +8,23 @@ And this partition should be formated to bcachefs.
2. Nyanit checks if bcachefs is encrypted, and asks for unlock password if it is. 2. Nyanit checks if bcachefs is encrypted, and asks for unlock password if it is.
3. Then it mounts it to **/mnt/bee-root**. 3. Then it mounts it to **/mnt/real-bee**.
4. And looks for snapshots with name pattern **/mnt/bee-root/bzz_snaps/bzz-yyyy-mm-ddTHH-MM-SS** 4. Now dealing with snapshoots. Its getting complicated because we need to have then outside root subvolume
Root subvolume should be named **bee-root**
Snapshoots made by hive-up should be placed in **bee-root/bzz-snaps** - **/mnt/real-bee/bee-root/bzz-snaps**
We need to transver snapshoot if any from **/mnt/real-bee/bee-root/bzz-snaps** to **/mnt/real-bee/bzz-snaps**
Snapshoots names should match **bzz-yyyy-mm-ddTHH-MM-SS** pattern.
5. If no snapshots are found it calls **switch_root** for **/mnt/bee-root** 4. And looks for snapshots with name pattern **/mnt/real-bee/bzz-snaps/bzz-yyyy-mm-ddTHH-MM-SS**
5. If no snapshots are found it calls **switch_root** for **/mnt/real-bee/bee-root**
6. Othervise vait for F2 for few seconds. 6. Othervise vait for F2 for few seconds.
And if F2 pressed provides list of snapshoots to boot from. And if F2 pressed provides list of snapshoots to boot from.
7. After some snapshoot or just **/mnt/bee-root** is selected, Nyanit doing **switch_root** to it. 7. After some snapshoot or just **/mnt/bee-root/real-bee** is selected, Nyanit doing **switch_root** to it.
8. TO-DO
- add cleaning of old snapshoots.
- add replacing bee-root with snapshoot
+6 -4
View File
@@ -40,8 +40,10 @@ const BEE_CAT: &str = include_str!("bee_cat.txt");
//const ROOT_PARTLABEL: &str = "bee-root"; //const ROOT_PARTLABEL: &str = "bee-root";
const ROOT_PARTLABEL: &str = "bee-root"; const ROOT_PARTLABEL: &str = "bee-root";
const TMP_ROOT: &str = "/mnt/bee_root"; const TMP_REAL_ROOT: &str = "/mnt/real-bee";
const TMP_ROOT_SNAPS: &str = "/mnt/bee_root/bzz_snaps"; const TMP_REAL_ROOT_SNAPS: &str = "/mnt/real-bee/bzz-snaps";
const TMP_ROOT: &str = "/mnt/real-bee/bee-root";
const TMP_ROOT_SNAPS: &str = "/mnt/real-bee/bee-root/bzz-snaps";
const SYS_INIT: &str = "/sbin/init"; const SYS_INIT: &str = "/sbin/init";
// fn bee_root_is_present() -> bool { // fn bee_root_is_present() -> bool {
@@ -76,13 +78,13 @@ enum NyanitState {
/// Mounting bee-root and chiking if there any snapshots /// Mounting bee-root and chiking if there any snapshots
fn mount_and_check_snaps(bee_root_dev: &str) -> Result<NyanitState, ExecCommandError> { fn mount_and_check_snaps(bee_root_dev: &str) -> Result<NyanitState, ExecCommandError> {
// mount bee-root // mount bee-root
nyan_system::mount_bee_root(bee_root_dev, TMP_ROOT)?; nyan_system::mount_bee_root(bee_root_dev, TMP_REAL_ROOT)?;
// let root_list = nyan_system::list_dir(TMP_ROOT)?; // let root_list = nyan_system::list_dir(TMP_ROOT)?;
// return Err(ExecCommandError::Other(root_list)); // return Err(ExecCommandError::Other(root_list));
// list snaps if any // list snaps if any
let mut snaps_list = nyan_system::list_bzzpss_snaps(TMP_ROOT_SNAPS)?; let mut snaps_list = nyan_system::list_bzzpss_snaps(TMP_REAL_ROOT_SNAPS)?;
// if any snaps detected whait for user to press F2 // if any snaps detected whait for user to press F2
if snaps_list.len() > 0 { if snaps_list.len() > 0 {
snaps_list.insert(0, TMP_ROOT.to_string()); snaps_list.insert(0, TMP_ROOT.to_string());
+1 -1
View File
@@ -251,7 +251,7 @@ pub fn bzzpss_dev_encrypted(dev_name: &str) -> Result<bool, ExecCommandError> {
//const TMP_ROOT: &str = "/mnt/bee-root"; //const TMP_ROOT: &str = "/mnt/bee-root";
pub fn list_bzzpss_snaps(snaps_dir: &str) -> Result<Vec<String>, ExecCommandError> { pub fn list_bzzpss_snaps(snaps_dir: &str) -> Result<Vec<String>, ExecCommandError> {
use regex::Regex; use regex_lite::Regex;
use std::path::Path; use std::path::Path;
// root snapshoot in a form of bzz-yyyy-mm-ddTHH-MM-SS // root snapshoot in a form of bzz-yyyy-mm-ddTHH-MM-SS