set timeout only if run in TTY

This commit is contained in:
Jakobus Schürz 2020-03-12 18:26:04 +01:00
parent 98b96b25e9
commit 04e217184d
2 changed files with 10 additions and 8 deletions

View file

@ -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

View file

@ -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