diff options
author | Marian Sigler <m@qjym.de> | 2013-02-28 16:30:45 +0100 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-02-28 16:40:46 +0100 |
commit | 25e85130acf689961a00d18cd1c8f265c5e9cd4c (patch) | |
tree | 37c519ad48dc0c3cefc470102ef05263823dcd6f /goodnight.sh | |
parent | 9ce996b12e44b30f1817b995b3be276f8a05b60f (diff) | |
download | goodnight-master.tar.gz goodnight-master.tar.bz2 goodnight-master.zip |
Diffstat (limited to 'goodnight.sh')
-rw-r--r-- | goodnight.sh | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/goodnight.sh b/goodnight.sh index 6439126..5473107 100644 --- a/goodnight.sh +++ b/goodnight.sh @@ -16,7 +16,7 @@ DEBUG="YES" # shift is considered started when the machine should run # returns 0 (==true) if the shift has started -function shifthasstarted () +shifthasstarted () { HOUR=$(date "+%k") if [ ${HOUR} -lt ${SHIFTEND} -a ${HOUR} -ge ${SHIFTSTART} ]; then @@ -27,7 +27,7 @@ function shifthasstarted () } # returns 0 if somebody is logged in -function somebodyisloggedin () +somebodyisloggedin () { r1=$(w -h | wc -l) # local users r2=$(ps ax | grep -e tmux -e SCREEN -e 'sshd:' | grep -v grep | wc -l) # remote users @@ -35,15 +35,16 @@ function somebodyisloggedin () } # only echos parameter if DEBUG is set to "YES" -function debug () +debug () { if [ $DEBUG = "YES" ]; then - echo $@ + echo "$@" fi } # Warten, bis alle Benutzer ausgeloggt -debug -n "waiting for all sessions to end" +debug -n "$(date +'[%F %T]') " +debug -n "waiting for all sessions to end " while somebodyisloggedin && ! shifthasstarted ; do debug -n "." sleep 300 @@ -51,13 +52,14 @@ done debug "" # Wenn es ausserhalb der Arbeitszeit ist herunterfahren. -debug "It is now $(date "+%H:%M")" +debug -n "$(date +'[%F %T]') " debug "Shift starts at ${SHIFTSTART} and ends at ${SHIFTEND}" +debug -n "$(date +'[%F %T]') " debug -n "Therefore I am " if shifthasstarted ; then - debug "Cancelling shutdown because it's my shift" + debug "cancelling shutdown because it's my shift" else - debug "Shutting down after an uptime of $(uptime | awk '{print $1}')" + debug "shutting down after an uptime of $(uptime | awk '{print $1}')" ${SHUTDOWN} fi exit 0 |