From 92c58b1f7c214bad0c3af61b8f7c38447e9c2915 Mon Sep 17 00:00:00 2001 From: Xavier Petit <32063953+xpetit@users.noreply.github.com> Date: Sun, 25 Aug 2019 19:25:39 +0100 Subject: [PATCH] Improve and debug login/logout scripts --- scripts/system/etc/gdm3/PostLogin/Default | 47 +++++++-------------- scripts/system/etc/gdm3/PostSession/Default | 10 ++--- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/scripts/system/etc/gdm3/PostLogin/Default b/scripts/system/etc/gdm3/PostLogin/Default index 904367da..e2aa9c68 100755 --- a/scripts/system/etc/gdm3/PostLogin/Default +++ b/scripts/system/etc/gdm3/PostLogin/Default @@ -25,39 +25,24 @@ PS4='-\D{%F %T} ' # Print commands and their arguments as they are executed. set -x -sleep 0.5 - -# Find the removable F2FS partition -PART=$(lsblk -pro kname,partlabel | grep 01-home | cut -d' ' -f1) - # Make sure the mountpoints are free -( - lsof -t $HOME | xargs kill -9 - umount $HOME - umount /mnt -) || true - -if test "$PART" -then - mount -o noatime "$PART" /mnt +kill $(lsof -t "$HOME" /mnt) ||: +umount "$HOME" /mnt ||: + +if test -e /dev/disk/by-partlabel/01-home; then + mount -o noatime /dev/disk/by-partlabel/01-home /mnt else - # No removable F2FS partition found - PART=$(lsblk -pro kname,partlabel | grep 01-tmp-home | cut -d' ' -f1) - - if test -z "$PART" - then - # No local partition found, error - exit 1 - fi - - # We don't care about data consistency since the partition is temporary - /sbin/mke2fs -t ext4 -O ^has_journal -F "$PART" - mount -o noatime,nobarrier "$PART" /mnt + # Fails if no local partition is found + test -e /dev/disk/by-partlabel/01-tmp-home || exit 1 + + # We don't care about data consistency since the partition is temporary so disable journaling + /sbin/mke2fs -t ext4 -O ^has_journal -F /dev/disk/by-partlabel/01-tmp-home + mount -o noatime,nobarrier /dev/disk/by-partlabel/01-tmp-home /mnt fi -USER_PATH=/mnt/.01/$USER -TEMP_PATH=/mnt/.01/tmp +user_path=/mnt/.01/"$USER" +temp_path=/mnt/.01/tmp -mkdir -p $USER_PATH $TEMP_PATH -chown -R $USER:$USER $USER_PATH $TEMP_PATH -mount -t overlay -o lowerdir=$HOME,upperdir=$USER_PATH,workdir=$TEMP_PATH overlay $HOME +mkdir -p "$user_path" "$temp_path" +chown -R "$USER":"$USER" "$user_path" "$temp_path" +mount -t overlay -o lowerdir="$HOME",upperdir="$user_path",workdir="$temp_path" overlay "$HOME" diff --git a/scripts/system/etc/gdm3/PostSession/Default b/scripts/system/etc/gdm3/PostSession/Default index 034bd6a8..8f2e9bb6 100755 --- a/scripts/system/etc/gdm3/PostSession/Default +++ b/scripts/system/etc/gdm3/PostSession/Default @@ -17,8 +17,8 @@ PS4='-\D{%F %T} ' set -x passwd -d $USER -sync -sleep 0.5 -lsof -t $HOME | xargs kill || true -umount -l $HOME -umount -l /mnt +systemctl stop user@1000.service + +# Make sure the mountpoints are free +kill $(lsof -t "$HOME" /mnt) $(ps --no-headers -u student -o pid) +umount "$HOME" /mnt