Browse Source

Improve and debug login/logout scripts

content-update
Xavier Petit 5 years ago
parent
commit
92c58b1f7c
No known key found for this signature in database
GPG Key ID: CA3F2B17E25ABD26
  1. 47
      scripts/system/etc/gdm3/PostLogin/Default
  2. 10
      scripts/system/etc/gdm3/PostSession/Default

47
scripts/system/etc/gdm3/PostLogin/Default

@ -25,39 +25,24 @@ PS4='-\D{%F %T} '
# Print commands and their arguments as they are executed. # Print commands and their arguments as they are executed.
set -x 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 # Make sure the mountpoints are free
( kill $(lsof -t "$HOME" /mnt) ||:
lsof -t $HOME | xargs kill -9 umount "$HOME" /mnt ||:
umount $HOME
umount /mnt if test -e /dev/disk/by-partlabel/01-home; then
) || true mount -o noatime /dev/disk/by-partlabel/01-home /mnt
if test "$PART"
then
mount -o noatime "$PART" /mnt
else else
# No removable F2FS partition found # Fails if no local partition is found
PART=$(lsblk -pro kname,partlabel | grep 01-tmp-home | cut -d' ' -f1) test -e /dev/disk/by-partlabel/01-tmp-home || exit 1
if test -z "$PART" # We don't care about data consistency since the partition is temporary so disable journaling
then /sbin/mke2fs -t ext4 -O ^has_journal -F /dev/disk/by-partlabel/01-tmp-home
# No local partition found, error mount -o noatime,nobarrier /dev/disk/by-partlabel/01-tmp-home /mnt
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
fi fi
USER_PATH=/mnt/.01/$USER user_path=/mnt/.01/"$USER"
TEMP_PATH=/mnt/.01/tmp temp_path=/mnt/.01/tmp
mkdir -p $USER_PATH $TEMP_PATH mkdir -p "$user_path" "$temp_path"
chown -R $USER:$USER $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 mount -t overlay -o lowerdir="$HOME",upperdir="$user_path",workdir="$temp_path" overlay "$HOME"

10
scripts/system/etc/gdm3/PostSession/Default

@ -17,8 +17,8 @@ PS4='-\D{%F %T} '
set -x set -x
passwd -d $USER passwd -d $USER
sync systemctl stop user@1000.service
sleep 0.5
lsof -t $HOME | xargs kill || true # Make sure the mountpoints are free
umount -l $HOME kill $(lsof -t "$HOME" /mnt) $(ps --no-headers -u student -o pid)
umount -l /mnt umount "$HOME" /mnt

Loading…
Cancel
Save