From f9f5f1b5824fb92f825cafa1036e4bf1ece909d8 Mon Sep 17 00:00:00 2001 From: xpetit <32063953+xpetit@users.noreply.github.com> Date: Sat, 29 May 2021 16:57:28 +0200 Subject: [PATCH] Fix numerous issues with login/logouts --- sh/debian/ubuntu/configure.sh | 6 +++++ .../ubuntu/system/etc/gdm3/PostLogin/Default | 10 +++----- .../system/etc/gdm3/PostSession/Default | 7 +----- .../ubuntu/system/usr/local/bin/reset_home | 25 +++++++++++++++++++ 4 files changed, 35 insertions(+), 13 deletions(-) create mode 100755 sh/debian/ubuntu/system/usr/local/bin/reset_home diff --git a/sh/debian/ubuntu/configure.sh b/sh/debian/ubuntu/configure.sh index c725cfa7..04ba8b1d 100755 --- a/sh/debian/ubuntu/configure.sh +++ b/sh/debian/ubuntu/configure.sh @@ -346,6 +346,12 @@ plymouth-quit-wait.service # shellcheck disable=2086 systemctl mask $services +# Logout quickly +cat <>/etc/systemd/logind.conf +KillUserProcesses=yes +UserStopDelaySec=0 +EOF + # Disable GTK hidden scroll bars echo GTK_OVERLAY_SCROLLING=0 >> /etc/environment diff --git a/sh/debian/ubuntu/system/etc/gdm3/PostLogin/Default b/sh/debian/ubuntu/system/etc/gdm3/PostLogin/Default index 367eb352..4cdf6f05 100755 --- a/sh/debian/ubuntu/system/etc/gdm3/PostLogin/Default +++ b/sh/debian/ubuntu/system/etc/gdm3/PostLogin/Default @@ -25,10 +25,6 @@ PS4='-\D{%F %T} ' # Print commands and their arguments as they are executed. set -x -# Make sure the mountpoints are free -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 @@ -45,6 +41,6 @@ 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 "$HOME"/.cache -mount -t tmpfs -o size=2G tmpfs "$HOME"/.cache +mount -t overlay -o lowerdir=/home/student,upperdir="$user_path",workdir="$temp_path" overlay /home/student +mkdir -p /home/student/.cache +mount -t tmpfs -o size=2G tmpfs /home/student/.cache diff --git a/sh/debian/ubuntu/system/etc/gdm3/PostSession/Default b/sh/debian/ubuntu/system/etc/gdm3/PostSession/Default index 4c8ebf67..60d8132d 100755 --- a/sh/debian/ubuntu/system/etc/gdm3/PostSession/Default +++ b/sh/debian/ubuntu/system/etc/gdm3/PostSession/Default @@ -17,10 +17,5 @@ PS4='-\D{%F %T} ' set -x passwd -d "$USER" ||: -systemctl stop user@1000.service -# Make sure the mountpoints are free -kill $(lsof -t "$HOME" /mnt) $(ps --no-headers -u "$USER" -o pid) -umount "$HOME"/.cache "$HOME" /mnt -umount /dev/disk/by-partlabel/01-home ||: -/usr/sbin/wipefs -a /dev/disk/by-partlabel/01-tmp-home +systemd-run /usr/local/bin/reset_home diff --git a/sh/debian/ubuntu/system/usr/local/bin/reset_home b/sh/debian/ubuntu/system/usr/local/bin/reset_home new file mode 100755 index 00000000..14383b2a --- /dev/null +++ b/sh/debian/ubuntu/system/usr/local/bin/reset_home @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Log stdout & stderr +exec > >(tee -i /tmp/reset_home.log) 2>&1 + +# Exit immediately if a command exits with a non-zero status. +set -e + +# The value of this parameter is expanded like PS1 and the expanded value is the +# prompt printed before the command line is echoed when the -x option is set +# (see The Set Builtin). The first character of the expanded value is replicated +# multiple times, as necessary, to indicate multiple levels of indirection. +# \D{%F %T} prints date like this : 2019-12-31 23:59:59 +PS4='-\D{%F %T} ' + +# Print commands and their arguments as they are executed. +set -x + +# Make sure the mountpoints are free +loginctl terminate-user student +sleep 0.1 + +umount /home/student/.cache /home/student /mnt +umount /dev/disk/by-partlabel/01-home ||: +/usr/sbin/wipefs -a /dev/disk/by-partlabel/01-tmp-home