diff options
author | Cecil <knoppmyth@gmail.com> | 2011-08-09 00:35:10 (GMT) |
---|---|---|
committer | Cecil <knoppmyth@gmail.com> | 2011-08-09 00:35:10 (GMT) |
commit | c7d475a307c528a21e994b30e36761ec84382e27 (patch) | |
tree | 4d58fc11d81f8322fb897f0e239dc3c8bb24f028 /abs/core/linhes-scripts/idle.sh | |
parent | 059553acb1fd81caac4cdf19ecbda399a0d83090 (diff) | |
parent | 8abd1b158d5998d04aeaba9a1c9554ce043d8aaa (diff) | |
download | linhes_pkgbuild-c7d475a307c528a21e994b30e36761ec84382e27.zip linhes_pkgbuild-c7d475a307c528a21e994b30e36761ec84382e27.tar.gz linhes_pkgbuild-c7d475a307c528a21e994b30e36761ec84382e27.tar.bz2 |
Merge branch 'testing' of ssh://cesman@linhes.org/mount/repository/linhes_pkgbuild into testing
Diffstat (limited to 'abs/core/linhes-scripts/idle.sh')
-rwxr-xr-x | abs/core/linhes-scripts/idle.sh | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/abs/core/linhes-scripts/idle.sh b/abs/core/linhes-scripts/idle.sh index f95b9fa..13fdb89 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 "hslt: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" |