From 04e217184d2fa1bc7d283e860aba7a7348e14343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Thu, 12 Mar 2020 18:26:04 +0100 Subject: [PATCH] set timeout only if run in TTY --- bashrc_add | 6 ------ myshell_load_defaults | 12 ++++++++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bashrc_add b/bashrc_add index 6e05545..628c507 100755 --- a/bashrc_add +++ b/bashrc_add @@ -10,12 +10,6 @@ if [ -z ${SSHS+x} ]; then SSHS=false;fi if [[ $- = *i* ]] ; then #echo "interactive shell" >&2 - case $(tty) in - /dev/tty[0-9]*) - echo "Run in TTY" ;; - *) - echo "Run in other terminal";; - esac # define variables [ -z "${MYSHELLCONFIIG_ROOT_TMOUT+x}" ] && MYSHELLCONFIIG_ROOT_TMOUT=500 [ -z "${MYSHELLCONFIIG_USER_TMOUT+x}" ] && MYSHELLCONFIIG_USER_TMOUT=0 diff --git a/myshell_load_defaults b/myshell_load_defaults index 876eeea..187539c 100644 --- a/myshell_load_defaults +++ b/myshell_load_defaults @@ -1,8 +1,16 @@ #!/bin/bash # if we are root, exit after 5 Minutes -[ $( id -u ) -eq 0 ] && TMOUT=${MYSHELLCONFIIG_ROOT_TMOUT} -[ $( id -u ) -gt 0 ] && TMOUT=${MYSHELLCONFIIG_USER_TMOUT} +case $(tty) in + /dev/tty[0-9]*) + echo "Run in TTY -> set autologout \$TMOUT=$TMOUT" >&2 + [ $( id -u ) -eq 0 ] && TMOUT=${MYSHELLCONFIIG_ROOT_TMOUT} + [ $( id -u ) -gt 0 ] && TMOUT=${MYSHELLCONFIIG_USER_TMOUT} + ;; + *) + echo "Run in other terminal" >&2 + ;; +esac # Load default values, functions, aliases for myshellconfig if ! $SSHS; then