From aa2eb62e775e7401891fea5adcc89f55b43111f0 Mon Sep 17 00:00:00 2001 From: "Kevin Veen-Birkenbach [aka. Frantz]" Date: Thu, 11 Jun 2020 11:41:51 +0200 Subject: [PATCH] Optimized umount procedures --- scripts/image/base.sh | 12 ++++++++++++ scripts/image/chroot.sh | 4 +--- scripts/image/setup.sh | 8 +------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/scripts/image/base.sh b/scripts/image/base.sh index 534dfd7..1d82fd5 100644 --- a/scripts/image/base.sh +++ b/scripts/image/base.sh @@ -50,6 +50,18 @@ mount_partitions(){ error } +umount_everything(){ + info "Unmounting everything..." && + (umount -lv "$chroot_dev_pts_mount_path" || warning "Umounting $chroot_dev_pts_mount_path failed!") && + (umount -lv "$chroot_dev_mount_path" || warning "Umounting $chroot_dev_mount_path failed!" ) && + (umount -v "$chroot_proc_mount_path" || warning "Umounting $chroot_proc_mount_path failed!" ) && + (umount -v "$chroot_sys_mount_path" || warning "Umounting $chroot_sys_mount_path failed!") && + (umount -v "$root_mount_path""boot/" || warning "Umounting $root_mount_path""boot/ failed!") && + (umount -v "$root_mount_path" || warning "Umounting $root_mount_path failed!") && + (umount -v "$boot_mount_path" || warning "Umounting $boot_mount_path failed!") || + warning "Failed." +} + mount_chroot_binds(){ info "Mount chroot environments..." && chroot_sys_mount_path="$root_mount_path""sys/" && diff --git a/scripts/image/chroot.sh b/scripts/image/chroot.sh index 22515bc..b751df8 100644 --- a/scripts/image/chroot.sh +++ b/scripts/image/chroot.sh @@ -5,9 +5,7 @@ source "$(dirname "$(readlink -f "${0}")")/base.sh" || (echo "Loading base.sh failed." && exit 1) destructor(){ - info "Unmount everything" && - umount "$root_mount_path"{dev/pts,dev,sys,proc,boot,} $boot_mount_path|| - warning "Failed." + umount_everything } info "Starting chroot..." diff --git a/scripts/image/setup.sh b/scripts/image/setup.sh index 532c797..6d7c31b 100644 --- a/scripts/image/setup.sh +++ b/scripts/image/setup.sh @@ -10,13 +10,7 @@ info "Setupscript for images started..." info "Define functions..." destructor(){ info "Cleaning up..." - umount -v "$chroot_dev_pts_mount_path" || warning "Umounting $chroot_dev_pts_mount_path failed!" - umount -v "$chroot_dev_mount_path" || warning "Umounting $chroot_dev_mount_path failed!" - umount -v "$chroot_proc_mount_path" || warning "Umounting $chroot_proc_mount_path failed!" - umount -v "$chroot_sys_mount_path" || warning "Umounting $chroot_sys_mount_path failed!" - umount -v "$root_mount_path""boot/" || warning "Umounting $root_mount_path""boot/ failed!" - umount -v "$root_mount_path" || warning "Umounting $root_mount_path failed!" - umount -v "$boot_mount_path" || warning "Umounting $boot_mount_path failed!" + umount_everything rmdir -v "$root_mount_path" || warning "Removing $root_mount_path failed!" rmdir -v "$boot_mount_path" || warning "Removing $boot_mount_path failed!" rmdir -v "$working_folder_path" || warning "Removing $working_folder_path failed!"