From c24780f2649acf0b8b0ef384eb4a1e95a4db61bf Mon Sep 17 00:00:00 2001 From: ItsDrike Date: Wed, 14 Jul 2021 14:27:41 +0200 Subject: [PATCH] Handle existing TMOUT --- root/etc/profile.d/shell-timeout.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/root/etc/profile.d/shell-timeout.sh b/root/etc/profile.d/shell-timeout.sh index aa99b77..8e8688c 100644 --- a/root/etc/profile.d/shell-timeout.sh +++ b/root/etc/profile.d/shell-timeout.sh @@ -4,13 +4,20 @@ # This will only be applied for non-graphical sessions, # or whenever root account is logged in -TMOUT=600 -readonly TMOUT +# If TMOUT was already set, unset it +unset TMOUT -[ -z "$DISPLAY" ] && export TMOUT; +# Define the timeout delay (seconds) +TIMEOUT=600 +# Set TMOUT when display is not set +[ -z "$DISPLAY" ] && export TMOUT=$TIMEOUT; + +# Set TMOUT when in TTY case $(/usr/bin/tty) in - /dev/tty[0-9]*) export TMOUT;; + /dev/tty[0-9]*) export TMOUT=$TIMEOUT;; esac -[ $UID -eq 0 ] && export TMOUT; +# Set TMOUT when user is root +[ $UID -eq 0 ] && export TMOUT=$TIMEOUT; +