use tty(1) to get the TTY of the current session
This commit is contained in:
parent
5a0603430a
commit
b1ae34fe47
|
@ -13,31 +13,27 @@ test -f /etc/evomaintenance.cf && . /etc/evomaintenance.cf
|
|||
[ -n "${HOSTNAME}" ] || HOSTNAME=$(hostname)
|
||||
[ -n "${EVOMAINTMAIL}" ] || EVOMAINTMAIL=evomaintenance-$(echo "${HOSTNAME}" | cut -d- -f1)@${REALM}
|
||||
|
||||
PATH=${PATH}:/usr/sbin
|
||||
|
||||
USER=$(logname)
|
||||
|
||||
BEGIN_YEAR=$(date "+%Y")
|
||||
|
||||
SYSTEME=$(uname -s)
|
||||
|
||||
if [ "${SYSTEME}" = "Linux" ]; then
|
||||
IP=$(LC_ALL=C who | grep $(ps -o tty= | tail -1) | tr -s ' ' | cut -d" " -f6 | sed -e "s/^(// ; s/)$//")
|
||||
|
||||
BEGIN_DATE=$(LC_ALL=C who | grep $(ps -o tty= | tail -1) | tr -s ' ' | cut -d" " -f3,4,5)
|
||||
|
||||
USER_TTY=$(tty | cut -d"/" -f3,4,5)
|
||||
LOGFILE_PERMS="root:adm"
|
||||
elif [ "${SYSTEME}" = "OpenBSD" ]; then
|
||||
IP=$(LC_ALL=C who | grep $(env | grep SSH_TTY | cut -d"/" -f3) | tr -s ' ' | cut -d" " -f6 | sed -e "s/^(// ; s/)$//")
|
||||
|
||||
BEGIN_DATE=$(LC_ALL=C who | grep $(env | grep SSH_TTY | cut -d"/" -f3) | tr -s ' ' | cut -d" " -f3,4,5)
|
||||
|
||||
USER_TTY=$(tty | cut -d"/" -f3)
|
||||
LOGFILE_PERMS="root:wheel"
|
||||
else
|
||||
echo "OS not detected!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
USER=$(logname)
|
||||
WHO=$(LC_ALL=C who | grep ${USER_TTY} | tr -s ' ')
|
||||
IP=$(echo ${WHO} | cut -d" " -f6 | sed -e "s/^(// ; s/)$//")
|
||||
BEGIN_DATE=$(echo ${WHO} | cut -d" " -f3,4,5)
|
||||
BEGIN_YEAR=$(date "+%Y")
|
||||
PATH=${PATH}:/usr/sbin
|
||||
|
||||
# log file
|
||||
LOGFILE=${LOGFILE:-/var/log/evomaintenance.log}
|
||||
touch "${LOGFILE}"
|
||||
|
|
Loading…
Reference in a new issue