From 1077333a6bf303746b2a4f5bc0edfa6df9b4d25f Mon Sep 17 00:00:00 2001 From: CyberLeo Date: Sat, 11 Feb 2012 17:26:03 -0600 Subject: [PATCH] update: unmount and remount any null mounts of /usr/ports during update --- update | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/update b/update index 86e883d..65daf41 100755 --- a/update +++ b/update @@ -89,6 +89,24 @@ done meh "Install" zfs set readonly=on "${prepare}" || wtf "readonly failed" + +# Remember and unmount any null-mounts of the filesystem that is about to be replaced +umount_and_generate_mount_lines() { + mount | grep '(nullfs, ' | grep "^/usr/ports " | while read null_src null_on null_dst null_opt + do + # Figure out if mount is read-only + mount_flags="" + case "${null_opt}" in + *read-only*) mount_flags="-r" + esac + # Craft a mount line + echo "echo '${null_dst}'; /sbin/mount -t nullfs ${mount_flags} '${null_src}' '${null_dst}';" + meh "Unmounting ${null_dst}" >&2 + /sbin/umount "${null_dst}" + done +} +remount_cmd="$(umount_and_generate_mount_lines)" + # Half of this is conditional on the old ports tree's existence [ -z "${ports_exists}" ] || zfs rename "${ports}" "${ports}-bak" || wtf "backup rename failed" zfs rename "${prepare}" "${ports}" || wtf "rename prepare -> ports failed" @@ -96,4 +114,8 @@ zfs rename "${prepare}" "${ports}" || wtf "rename prepare -> ports failed" zfs set mountpoint="${ports_fs}" "${ports}" || wtf "mountpoint failed" [ -z "${ports_exists}" ] || zfs destroy "${ports}-bak" || wtf "destroy failed" +# Remount null-mounts of this filesystem +[ "${remount_cmd}" ] && meh "Remounting filesystems" +eval "${remount_cmd}" + meh "All done" -- 2.42.0