SHA256
Compare commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
9601cc300b |
Generated
+1
-1
@@ -305,7 +305,7 @@ checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nyanit"
|
name = "nyanit"
|
||||||
version = "0.1.7"
|
version = "0.1.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"nix",
|
"nix",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nyanit"
|
name = "nyanit"
|
||||||
version = "0.1.7"
|
version = "0.1.8"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
+18
-7
@@ -90,17 +90,26 @@ fn mount_and_check_snaps(bee_root_dev: &str) -> Result<NyanitState, ExecCommandE
|
|||||||
Ok(NyanitState::HandOff(TMP_ROOT.into()))
|
Ok(NyanitState::HandOff(TMP_ROOT.into()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn init_stage() -> Result<(String, NyanitState), ExecCommandError> {
|
fn init_stage() -> Result<(String, NyanitState), ExecCommandError> {
|
||||||
// mount sysfss
|
// mount sysfss
|
||||||
nyan_system::prepare_env().map_err(|ex| format!("prepare_env error: {}", ex))?;
|
nyan_system::prepare_env().map_err(|ex| format!("prepare_env error: {}", ex))?;
|
||||||
|
|
||||||
// get bee-root device name aka /dev/sda1
|
// get bee-root device name aka /dev/sda1
|
||||||
let bee_root_dev = match nyan_system::find_partlabel(ROOT_PARTLABEL) {
|
|
||||||
Err(_ex) => {
|
let mut maybe_bee_root_dev = nyan_system::find_partlabel(ROOT_PARTLABEL);
|
||||||
return Err(ExecCommandError::Other(nyan_system::list_partlabel().unwrap()))
|
if maybe_bee_root_dev.is_err() {
|
||||||
},
|
for _i in 0u32..5 {
|
||||||
Ok(v)=>v
|
thread::sleep(Duration::from_millis(100));
|
||||||
};
|
maybe_bee_root_dev = nyan_system::find_partlabel(ROOT_PARTLABEL);
|
||||||
|
if maybe_bee_root_dev.is_ok() {
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let bee_root_dev= maybe_bee_root_dev?;
|
||||||
|
|
||||||
// check if device is encrypted
|
// check if device is encrypted
|
||||||
if nyan_system::bzzpss_dev_encrypted(&bee_root_dev).map_err(|ex| format!("Error checking if device is encrypted: {}", ex))? {
|
if nyan_system::bzzpss_dev_encrypted(&bee_root_dev).map_err(|ex| format!("Error checking if device is encrypted: {}", ex))? {
|
||||||
// if encrypted return EnterPassword so used get promted for pass
|
// if encrypted return EnterPassword so used get promted for pass
|
||||||
@@ -110,6 +119,7 @@ fn init_stage() -> Result<(String, NyanitState), ExecCommandError> {
|
|||||||
// if unencrypted
|
// if unencrypted
|
||||||
let check_res = mount_and_check_snaps(&bee_root_dev)?;
|
let check_res = mount_and_check_snaps(&bee_root_dev)?;
|
||||||
Ok((bee_root_dev, check_res))
|
Ok((bee_root_dev, check_res))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NyanitTUI<'a> {
|
struct NyanitTUI<'a> {
|
||||||
@@ -138,7 +148,8 @@ impl NyanitTUI<'_> {
|
|||||||
self.state = match init_stage() {
|
self.state = match init_stage() {
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
self.bee_root_dev = res.0;
|
self.bee_root_dev = res.0;
|
||||||
res.1
|
//res.1
|
||||||
|
NyanitState::Error(format!("bee_root_dev={} END EVERYTHING IS READY", self.bee_root_dev))
|
||||||
},
|
},
|
||||||
Err(ex) => {
|
Err(ex) => {
|
||||||
NyanitState::Error(format!("Error while trying to bzzz-pss things:\n{}", ex))
|
NyanitState::Error(format!("Error while trying to bzzz-pss things:\n{}", ex))
|
||||||
|
|||||||
+36
-2
@@ -22,6 +22,10 @@ use nix;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
|
|
||||||
|
// timeout for block deices population
|
||||||
|
const WAIT_FOR_BLK_DEVS: u64 = 5u64;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct CommandFailed {
|
pub struct CommandFailed {
|
||||||
pub stderr: Vec<u8>,
|
pub stderr: Vec<u8>,
|
||||||
@@ -260,6 +264,29 @@ pub fn list_bzzpss_snaps(snaps_dir: &str) -> Result<Vec<String>, ExecCommandErro
|
|||||||
Ok(res)
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// pulls /sys/class/block
|
||||||
|
fn wait_for_block_devices(timeout_secs: u64) -> bool {
|
||||||
|
use std::path::Path;
|
||||||
|
use std::{thread, time::Duration};
|
||||||
|
|
||||||
|
let start = std::time::Instant::now();
|
||||||
|
while start.elapsed().as_secs() < timeout_secs {
|
||||||
|
// Check if any block device exists (e.g., sda, nvme0n1, vda)
|
||||||
|
// You can refine this to check for a specific device needed for root
|
||||||
|
if Path::new("/sys/class/block").read_dir().ok()
|
||||||
|
.and_then(|mut d| d.next().is_some().then_some(true))
|
||||||
|
.unwrap_or(false)
|
||||||
|
{
|
||||||
|
// Optional: Verify specific device needed for root exists
|
||||||
|
// if Path::new("/dev/nvme0n1").exists() { return true; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
thread::sleep(Duration::from_millis(100));
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
// mounting process
|
// mounting process
|
||||||
//# Mount essential virtual filesystems
|
//# Mount essential virtual filesystems
|
||||||
// mount -t proc none /proc
|
// mount -t proc none /proc
|
||||||
@@ -291,15 +318,22 @@ pub fn prepare_env() -> Result<(), String> {
|
|||||||
)
|
)
|
||||||
.map_err(|ex| format!("Error mounting /sys: {}", ex.to_string()))?;
|
.map_err(|ex| format!("Error mounting /sys: {}", ex.to_string()))?;
|
||||||
|
|
||||||
|
if wait_for_block_devices(WAIT_FOR_BLK_DEVS) == false {
|
||||||
|
return Err("Waiting for block devices to get populated timed out.".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
let dev_mount_flags = MsFlags::MS_NOSUID | MsFlags::MS_RELATIME;
|
||||||
mount(
|
mount(
|
||||||
Some("devtmpfs"),
|
Some("devtmpfs"),
|
||||||
"/dev",
|
"/dev",
|
||||||
Some("devtmpfs"),
|
Some("devtmpfs"),
|
||||||
MsFlags::empty(),
|
dev_mount_flags,
|
||||||
None::<&str>,
|
Some("mode=0755"),
|
||||||
)
|
)
|
||||||
.map_err(|ex| format!("Error mounting /dev: {}", ex.to_string()))?;
|
.map_err(|ex| format!("Error mounting /dev: {}", ex.to_string()))?;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// modprobe bcachefs
|
// modprobe bcachefs
|
||||||
// exec_command("modprobe", &vec!["bcachefs"])?;
|
// exec_command("modprobe", &vec!["bcachefs"])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user