From 9d95d60184c2f9c2737e6903ed1b45cb2783d7c7 Mon Sep 17 00:00:00 2001 From: Michael Hanson Date: Mon, 8 Aug 2011 22:44:56 +0000 Subject: linhes-scripts: Add login check to idle.sh. Ref #755 --- abs/core/linhes-scripts/PKGBUILD | 4 ++-- abs/core/linhes-scripts/idle.sh | 21 ++++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/abs/core/linhes-scripts/PKGBUILD b/abs/core/linhes-scripts/PKGBUILD index 076bac7..f3204b1 100644 --- a/abs/core/linhes-scripts/PKGBUILD +++ b/abs/core/linhes-scripts/PKGBUILD @@ -3,7 +3,7 @@ pkgname=linhes-scripts pkgver=7 -pkgrel=4 +pkgrel=5 pkgdesc="Various scripts that help to make LinHES, LinHES." arch=('i686' 'x86_64') license=('GPL2') @@ -74,7 +74,7 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5' '3b776bbff68906ddc2f62b7e0dde3fe4' '15f3143d2b1369da431e4268029aba40' '3d0adf26280cde55a0c47188fff34826' - '93aaa2940e33ec9ebb305b839ac46a3e' + 'c5f55f7fb02e8e7aed62192363c2c201' 'b2c3dd48a4abb976eda2d5fbf22a173a' 'b527b01d119d3bc33b8fa69bdf1082bb' 'c537c44156d8404016cc4b405b092d45' diff --git a/abs/core/linhes-scripts/idle.sh b/abs/core/linhes-scripts/idle.sh index f95b9fa..3ad8135 100755 --- a/abs/core/linhes-scripts/idle.sh +++ b/abs/core/linhes-scripts/idle.sh @@ -1,11 +1,12 @@ #!/bin/bash usage () { - echo "Usage: $0 [-h] [-s] [-t ]" + echo "Usage: $0 [-h] [-s] [-t ] [-l] [-v]" echo echo "-h - Print this help/usage message and quit" echo "-s - Run silently (default is verbose)" echo "-t - Minutes of idle time needed (default is 20)" + echo "-l - Check for user logins (default: false - do not check)" echo "-v - Be more verbose for debugging" echo echo "Silent mode is recommended for use in cron jobs or scripts." @@ -22,14 +23,16 @@ mysql_cmd () { # Command line argument handling VERBOSE=1 +LOGINS=0 TIME_BEFORE=20 TIME_AFTER=5 # Only adjustable by editing here -while getopts "hst:v" OPT ; do +while getopts "hstl:v" OPT ; do case $OPT in h) usage 0 ;; s) VERBOSE=0 ;; t) TIME_BEFORE=$OPTARG ;; + l) LOGINS=1 ;; v) VERBOSE=2 ;; *) usage 1 ;; esac @@ -91,7 +94,19 @@ if [ "$VERBOSE" -ge 2 ] ; then item += 1; }' fi -activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING)) + +if [ "$LOGINS" -ge 1 ] ; then + USERS=`/usr/bin/last | /bin/grep "still logged in" | awk '{ print $1 }'` + if [ -n "$USERS" ] ; then + LOGINS=1 + msg "The following user(s) are still logged in: ${USERS}" + else + LOGINS=0 + msg "No user(s) are logged in..." + fi +fi + +activities=$(($BUSY + $SCHEMALOCK + $JOBS + $INUSE + $UPCOMING + $LOGINS)) msg if [ "$activities" -eq 0 ] ; then msg "System is idle" -- cgit v0.12 From 8abd1b158d5998d04aeaba9a1c9554ce043d8aaa Mon Sep 17 00:00:00 2001 From: Michael Hanson Date: Mon, 8 Aug 2011 23:09:04 +0000 Subject: linhes-scripts: Fix typo in idle.sh Ref #755 --- abs/core/linhes-scripts/PKGBUILD | 4 ++-- abs/core/linhes-scripts/idle.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/abs/core/linhes-scripts/PKGBUILD b/abs/core/linhes-scripts/PKGBUILD index f3204b1..0b5c2a9 100644 --- a/abs/core/linhes-scripts/PKGBUILD +++ b/abs/core/linhes-scripts/PKGBUILD @@ -3,7 +3,7 @@ pkgname=linhes-scripts pkgver=7 -pkgrel=5 +pkgrel=6 pkgdesc="Various scripts that help to make LinHES, LinHES." arch=('i686' 'x86_64') license=('GPL2') @@ -74,7 +74,7 @@ md5sums=('f56985b2d602e11dc1e10d3e7848b2a5' '3b776bbff68906ddc2f62b7e0dde3fe4' '15f3143d2b1369da431e4268029aba40' '3d0adf26280cde55a0c47188fff34826' - 'c5f55f7fb02e8e7aed62192363c2c201' + '7ffe9cea9c5604b696a2a1d274c21ac3' 'b2c3dd48a4abb976eda2d5fbf22a173a' 'b527b01d119d3bc33b8fa69bdf1082bb' 'c537c44156d8404016cc4b405b092d45' diff --git a/abs/core/linhes-scripts/idle.sh b/abs/core/linhes-scripts/idle.sh index 3ad8135..13fdb89 100755 --- a/abs/core/linhes-scripts/idle.sh +++ b/abs/core/linhes-scripts/idle.sh @@ -27,7 +27,7 @@ LOGINS=0 TIME_BEFORE=20 TIME_AFTER=5 # Only adjustable by editing here -while getopts "hstl:v" OPT ; do +while getopts "hslt:v" OPT ; do case $OPT in h) usage 0 ;; s) VERBOSE=0 ;; -- cgit v0.12