Skip to content

Commit 6d91a87

Browse files
committed
fnify
1 parent bdfdeca commit 6d91a87

3 files changed

Lines changed: 18 additions & 24 deletions

File tree

src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,15 @@ fn write_group_report(
176176
}
177177
Ok(())
178178
}
179+
180+
async fn booted_under_edera(host_executor: &HostNamespaceExecutor) -> Result<bool> {
181+
host_executor
182+
.spawn_in_host_ns(async {
183+
if !Path::new("/var/lib/edera/protect/.install-completed").exists() {
184+
return false;
185+
}
186+
let xen = Path::new("/sys/hypervisor/type");
187+
xen.exists() && fs::read_to_string(xen).unwrap_or_default().trim() == "xen"
188+
})
189+
.await.context("failed to check Edera boot status")
190+
}

src/postinstall_cmd.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::checkers::postinstall::{
44
};
55

66
use crate::recorders::postinstall::system::SystemRecorder as postrecorder;
7-
use crate::{create_base_path, create_gzip_from, write_group_report};
7+
use crate::{booted_under_edera, create_base_path, create_gzip_from, write_group_report};
88

99
use anyhow::Result;
1010
use console::style;
@@ -37,16 +37,7 @@ pub async fn do_postinstall(
3737

3838
// See if we are booted under Edera. If not, error out and suggest `preinstall`
3939
// as the command to run.
40-
match host_executor
41-
.spawn_in_host_ns(async {
42-
if !Path::new("/var/lib/edera/protect/.install-completed").exists() {
43-
return false;
44-
}
45-
let xen = Path::new("/sys/hypervisor/type");
46-
xen.exists() && fs::read_to_string(xen).unwrap_or_default().trim() == "xen"
47-
})
48-
.await
49-
{
40+
match booted_under_edera(&host_executor).await {
5041
Ok(true) => {}
5142
Ok(false) => {
5243
println!(

src/preinstall_cmd.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::checkers::preinstall::{
33
pvh::PVHChecks, system::SystemChecks,
44
};
55

6-
use crate::{create_base_path, create_gzip_from, write_group_report};
6+
use crate::{booted_under_edera, create_base_path, create_gzip_from, write_group_report};
77
use anyhow::Result;
88
use console::style;
99

@@ -18,8 +18,8 @@ use crate::recorders::preinstall::system::SystemRecorder as prerecorder;
1818
use anyhow::{anyhow, bail};
1919
use std::{
2020
collections::HashSet,
21-
env, fs,
22-
path::{Path, PathBuf},
21+
env,
22+
path::PathBuf,
2323
process,
2424
};
2525

@@ -38,16 +38,7 @@ pub async fn do_preinstall(
3838

3939
// See if we are already booted under Edera. If so, error out and suggest `postinstall`
4040
// as the command to run.
41-
match host_executor
42-
.spawn_in_host_ns(async {
43-
if !Path::new("/var/lib/edera/protect/.install-completed").exists() {
44-
return false;
45-
}
46-
let xen = Path::new("/sys/hypervisor/type");
47-
xen.exists() && fs::read_to_string(xen).unwrap_or_default().trim() == "xen"
48-
})
49-
.await
50-
{
41+
match booted_under_edera(&host_executor).await {
5142
Ok(true) => {
5243
println!(
5344
"{}",

0 commit comments

Comments
 (0)