summaryrefslogtreecommitdiffstats
path: root/abs
diff options
context:
space:
mode:
authorMichael Hanson <hansonorders@verizon.net>2011-08-08 22:44:56 (GMT)
committerMichael Hanson <hansonorders@verizon.net>2011-08-08 22:44:56 (GMT)
commit9d95d60184c2f9c2737e6903ed1b45cb2783d7c7 (patch)
tree466328b57ecb70e2cf7ad7f3ec7ae178837bef1b /abs
parent59a5989953eff908ea42f588aa029c1b897f16a5 (diff)
downloadlinhes_pkgbuild-9d95d60184c2f9c2737e6903ed1b45cb2783d7c7.zip
linhes_pkgbuild-9d95d60184c2f9c2737e6903ed1b45cb2783d7c7.tar.gz
linhes_pkgbuild-9d95d60184c2f9c2737e6903ed1b45cb2783d7c7.tar.bz2
linhes-scripts: Add login check to idle.sh. Ref #755
Diffstat (limited to 'abs')
-rw-r--r--abs/core/linhes-scripts/PKGBUILD4
-rwxr-xr-xabs/core/linhes-scripts/idle.sh21
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 <minutes_needed>]"
+ echo "Usage: $0 [-h] [-s] [-t <minutes_needed>] [-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"