1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
#!/bin/sh
trap "" 0 1 2 15
LOG=/tmp/w.log.$$
dialog --clear
w | egrep -v tty[1-8] | tail +2 > $LOG
count=`wc -l < $LOG`
dont_panic() {
dialog --infobox "
THE SYSTEM IS SHUTTING DOWN
!!!!!!!WAIT!!!!!!
!!!!DON'T POWER DOWN YET!!!!!!!!
wait for this message to clear.
$*
" 15 60 &
}
if [ $count -lt 2 ]; then
dont_panic "
The system is shutting down"
/sbin/shutdown -r now "sistema esta en shutdown"
else
dialog --yesno "
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
There are the following remote users in
the machine:
`cat $LOG`
Shutdown will be delayed by 2 minutes
inorder to warn the remote users.
Do you still want to start the shutdown?
" 22 60
if [ $? = 0 ];then
dont_panic "
Shutting down in 2 minutes"
/sbin/shutdown -r +2 "sistema esta en shutdown"
else
sleep 1
dialog --infobox "
The shutdown has been aborted
" 7 50 &
sleep 5
dialog --clear
fi
fi
|