fix update-grub2

This commit is contained in:
Aiden McClelland
2023-06-16 18:03:50 -06:00
committed by Aiden McClelland
parent 90424e8329
commit e95d56a5d0
4 changed files with 17 additions and 24 deletions

View File

@@ -254,7 +254,7 @@ pub async fn list(os: &OsPartitionInfo) -> Result<Vec<DiskInfo>, Error> {
parts: BTreeSet<PathBuf>, parts: BTreeSet<PathBuf>,
internal: bool, internal: bool,
} }
let disk_guids = dbg!(pvscan().await?); let disk_guids = pvscan().await?;
let disks = tokio_stream::wrappers::ReadDirStream::new( let disks = tokio_stream::wrappers::ReadDirStream::new(
tokio::fs::read_dir(DISK_PATH) tokio::fs::read_dir(DISK_PATH)
.await .await

View File

@@ -265,6 +265,12 @@ pub async fn execute(
.invoke(crate::ErrorKind::OpenSsh) .invoke(crate::ErrorKind::OpenSsh)
.await?; .await?;
let dev = MountGuard::mount(
&Bind::new(rootfs.as_ref()),
current.join("media/embassy/embassyfs"),
MountType::ReadOnly,
)
.await?;
let dev = MountGuard::mount(&Bind::new("/dev"), current.join("dev"), ReadWrite).await?; let dev = MountGuard::mount(&Bind::new("/dev"), current.join("dev"), ReadWrite).await?;
let proc = MountGuard::mount(&Bind::new("/proc"), current.join("proc"), ReadWrite).await?; let proc = MountGuard::mount(&Bind::new("/proc"), current.join("proc"), ReadWrite).await?;
let sys = MountGuard::mount(&Bind::new("/sys"), current.join("sys"), ReadWrite).await?; let sys = MountGuard::mount(&Bind::new("/sys"), current.join("sys"), ReadWrite).await?;
@@ -297,6 +303,12 @@ pub async fn execute(
.invoke(crate::ErrorKind::Grub) .invoke(crate::ErrorKind::Grub)
.await?; .await?;
Command::new("chroot")
.arg(&current)
.arg("update-grub2")
.invoke(crate::ErrorKind::Grub)
.await?;
dev.unmount(false).await?; dev.unmount(false).await?;
if let Some(efivarfs) = efivarfs { if let Some(efivarfs) = efivarfs {
efivarfs.unmount(false).await?; efivarfs.unmount(false).await?;

View File

@@ -25,6 +25,7 @@ libavahi-client3
lm-sensors lm-sensors
lvm2 lvm2
magic-wormhole magic-wormhole
man-db
ncdu ncdu
net-tools net-tools
network-manager network-manager

View File

@@ -3,28 +3,8 @@
ARGS= ARGS=
for ARG in $@; do for ARG in $@; do
if [ "${ARG%%[!/]*}" = "/" ]; then if [ -d "/media/embassy/embassyfs" ] && [ "$ARG" = "/" ]; then
ARG=/media/embassy/embassyfs
OPTIONS=
path="$ARG"
while true; do
if FSTYPE=$( findmnt -n -o FSTYPE "$path" ); then
if [ "$FSTYPE" = "overlay" ]; then
OPTIONS=$(findmnt -n -o OPTIONS "$path")
break
else
break
fi
fi
if [ "$path" = "/" ]; then break; fi
path=$(dirname "$path")
done
if LOWERDIR=$(echo "$OPTIONS" | grep -m 1 -oP 'lowerdir=\K[^,]+'); then
#echo "[DEBUG] Overlay filesystem detected ${ARG} --> ${LOWERDIR}${ARG%*/}" 1>&2
ARG=/media/embassy/embassyfs"${ARG%*/}"
fi
fi fi
ARGS="$ARGS $ARG" ARGS="$ARGS $ARG"
done done