X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=mount-latest-subvol;h=36895aa1612ad1d58bc923775d19887117fdf60f;hb=f0a35267f28e274ef3c2f63ffc20a26ca864e37c;hp=1b0a8e23123201182ac5eb0d7a99ca626f982652;hpb=86ebcd0416223ded297f6cbbcb0906b85793e359;p=distro-setup diff --git a/mount-latest-subvol b/mount-latest-subvol index 1b0a8e2..36895aa 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -81,6 +81,33 @@ fstab() { tu /etc/fstab <<<"$l" done } +kill-dir() { + for sig; do + echo kill-dir $sig + found_pids=false + if pids=$(timeout 4 lsof -t $dir); then + found_pids=true + timeout 4 lsof -w $dir + kill -$sig $pids + fi + # fuser will find open sockets that lsof won't, for example from gpg-agent. + # note: -v shows kernel processes, which then doesn't return true when we want + if timeout 4 fuser -m $dir &>/dev/null; then + found_pids=true + fuser -$sig -mvk $dir + fi + sleep .5 + if ! $found_pids; then + return 0 + fi + done + return 1 +} + +force=false +if [[ $1 == -f ]]; then + force=true +fi ret=0 @@ -89,16 +116,29 @@ first_root_crypt=$(awk '$2 == "/" {print $1}' /etc/mtab) fstab <