From 0da743696d0afb093cf95c905a33acbce27ead32 Mon Sep 17 00:00:00 2001 From: Robert DeBartolo Date: Fri, 22 May 2020 00:52:13 -0500 Subject: [PATCH 1/2] Hook into SDDM close-down routine to ensure ZFS homedirs are unmount without hardcoded homedirs --- .../usr/share/sddm/scripts/Xstop.trident | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/void-desktop-files/usr/share/sddm/scripts/Xstop.trident b/void-desktop-files/usr/share/sddm/scripts/Xstop.trident index 6641b72..dd2d8dd 100755 --- a/void-desktop-files/usr/share/sddm/scripts/Xstop.trident +++ b/void-desktop-files/usr/share/sddm/scripts/Xstop.trident @@ -8,16 +8,12 @@ # CAVEATS: Assumes that the user homedir is always /usr/home/[username] # This will need to be fixed later # =============================== -ulist=$(users) -for dir in $(ls /usr/home) -do - echo "${ulist}" | grep -q "${dir}" - if [ $? -ne 0 ] ; then - #User not logged in any more - mount | grep -q "on /usr/home/${dir} type zfs" - if [ $? -eq 0 ] ; then - #Homedir is a still-mounted ZFS dataset - zfs unmount -f /usr/home/${dir} - fi - fi -done + +ulist=$(last | awk 'NR==1 {print $1}' | grep -f - /etc/passwd | cut -d":" -f6 | tee) + +if [ $? -ne '0' ] ; then + exit +else + umount -R ${ulist} + zfs unmount -f ${ulist} +fi From e11f13e385610f728bd84e9ab656e8b63bc9d15a Mon Sep 17 00:00:00 2001 From: Robert DeBartolo Date: Fri, 22 May 2020 00:58:58 -0500 Subject: [PATCH 2/2] Hook into SDDM close-down routine to ensure ZFS homedirs are unmount without hardcoded homedirs comments --- void-desktop-files/usr/share/sddm/scripts/Xstop.trident | 3 +++ 1 file changed, 3 insertions(+) diff --git a/void-desktop-files/usr/share/sddm/scripts/Xstop.trident b/void-desktop-files/usr/share/sddm/scripts/Xstop.trident index dd2d8dd..19029cd 100755 --- a/void-desktop-files/usr/share/sddm/scripts/Xstop.trident +++ b/void-desktop-files/usr/share/sddm/scripts/Xstop.trident @@ -9,11 +9,14 @@ # This will need to be fixed later # =============================== +# Use last to get the last user logged in and grep for that users homedir pipe to text. ulist=$(last | awk 'NR==1 {print $1}' | grep -f - /etc/passwd | cut -d":" -f6 | tee) if [ $? -ne '0' ] ; then + # Safety exit else + # No errors good. Finally unmount the dataset umount -R ${ulist} zfs unmount -f ${ulist} fi