Debian Codegraph @

src/cad

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