SHA256
Trying to figure out blkid thing. Add --probe flag.
This commit is contained in:
Generated
+1
-1
@@ -305,7 +305,7 @@ checksum = "6aa2c4e539b869820a2b82e1aef6ff40aa85e65decdd5185e83fb4b1249cd00f"
|
||||
|
||||
[[package]]
|
||||
name = "nyanit"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"nix",
|
||||
"ratatui",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "nyanit"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
+7
-2
@@ -41,7 +41,7 @@ const BEE_CAT: &str = include_str!("bee_cat.txt");
|
||||
//const ROOT_PARTLABEL: &str = "bee-root";
|
||||
const ROOT_PARTLABEL: &str = "bee-root";
|
||||
const TMP_ROOT: &str = "/mnt/bee_root";
|
||||
const TMP_ROOT_SNAPS: &str = "/mnt/bee-root/bzz_snaps";
|
||||
const TMP_ROOT_SNAPS: &str = "/mnt/bee_root/bzz_snaps";
|
||||
const SYS_INIT: &str = "/sbin/init";
|
||||
|
||||
// fn bee_root_is_present() -> bool {
|
||||
@@ -95,7 +95,12 @@ fn init_stage() -> Result<(String, NyanitState), ExecCommandError> {
|
||||
nyan_system::prepare_env().map_err(|ex| format!("prepare_env error: {}", ex))?;
|
||||
|
||||
// get bee-root device name aka /dev/sda1
|
||||
let bee_root_dev = nyan_system::find_partlabel(ROOT_PARTLABEL)?;
|
||||
let bee_root_dev = match nyan_system::find_partlabel(ROOT_PARTLABEL) {
|
||||
Err(_ex) => {
|
||||
return Err(ExecCommandError::Other(nyan_system::list_partlabel().unwrap()))
|
||||
},
|
||||
Ok(v)=>v
|
||||
};
|
||||
// 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 encrypted return EnterPassword so used get promted for pass
|
||||
|
||||
@@ -115,6 +115,7 @@ pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError>
|
||||
pub fn find_partlabel(partlabel: &str) -> Result<String, ExecCommandError> {
|
||||
let out = Command::new("/usr/bin/blkid")
|
||||
.args([
|
||||
"--probe",
|
||||
"-s",
|
||||
"PARTLABEL",
|
||||
"--match-token",
|
||||
@@ -138,6 +139,19 @@ pub fn find_partlabel(partlabel: &str) -> Result<String, ExecCommandError> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pub fn list_partlabel() -> Result<String, ExecCommandError> {
|
||||
let out = Command::new("/usr/bin/blkid")
|
||||
.args(["--probe", "-s", "PARTLABEL"])
|
||||
.output()?;
|
||||
if out.status.success() {
|
||||
let out_text = String::from_utf8(out.stdout)?;
|
||||
Ok(out_text)
|
||||
} else {
|
||||
Err(ExecCommandError::Other("Oh no".to_string()))
|
||||
}
|
||||
}
|
||||
|
||||
/// exec given command with arguments, returning stdout parsed to UTF-8 string
|
||||
/// capturing stderr in case or failure
|
||||
// pub fn exec_command_out(cmd: &str, args: &Vec<&str>) -> Result<String, ExecCommandError> {
|
||||
|
||||
Reference in New Issue
Block a user