2 # Sample Event Script written by Bob Perry
4 # Enters via the avr_evtd daemon with the following command options:
5 # 0 - Special event following double press of the 'red' reset button
6 # 1 - AVR device has requested a halt due to error
7 # 2 - Shutdown request from timed shutdown logic
8 # 3 - User has released the power button
9 # 4 - User has pressed the power button
10 # 5 - User has released the 'red' reset button
11 # 6 - User has pressed the reset button
12 # 7 - User has held the power button > 3 seconds
13 # 8 - User has held the reset button > 3 seconds
14 # 9 - Disk used beyond DISKCHECK%
15 # F - Fan failure event, fan stopped for > FANSTOP seconds
16 # E - User selected EM-Mode
17 # S - Five minute shutdown warning event
18 # D - Error message handler
22 PATH
=/sbin
:/bin
:/usr
/sbin
:/usr
/bin
:/usr
/local
/sbin
26 .
/etc
/default
/avr_evtd
28 if [ "$DEBUG" = "ON" ] && [ -d "$LOG" ]; then
29 echo "`date` command is $1[$3] for $DEVICE" >> $LOG/avr_evtd.log
32 if [ -f "/tmp/.inst-instflashing" ] ; then
33 if [ ! -f "/tmp/.inst-instdone" ] ; then
40 1) # Indicate this mode by flashing the DISK FULL LED
41 echo -n "YYYY" > $DEVICE
42 # Add an EM IP address or if no ethernet, start it up
44 route
-n |
grep -q eth0
&& FAIL
=0
45 if [ "$FAIL" -eq 0 ]; then
47 route
-n |
grep -q 192.168.11.0 && FAIL
=0
48 if [ "$FAIL" -eq 1 ]; then
49 ifconfig eth0
:EM
192.168.11.150 netmask
255.255.255.0 up
52 /sbin
/ifup
--force -a -i /etc
/avr_evtd
/emergency_eth0
54 route add
-net 192.168.11.0 netmask
255.255.255.255.0 eth0
:EM
56 if [ -e /sbin
/utelnetd
]; then
57 utelnetd
-p 1234 -l /bin
/bash
&
59 3) # Flash more lights to indicate we are desperate
60 echo -n "SSSS" > $DEVICE
64 3) echo -n "[avr_evtd]: Power Button Up"
66 4) echo -n "[avr_evtd]: Power Button Down"
68 5) echo -n "[avr_evtd]: Reset Button Up"
70 6) echo -n "[avr_evtd]: Reset Button Down"
72 1|
2|
7) echo -n "[avr_evtd]: Shutdown"
73 if [ ! "$NOCMD" = "1" ] ; then
74 echo -n "EEEE" > $DEVICE
77 8) echo -n "[avr_evtd]: User demanded reset"
78 if [ ! "$NOCMD" = "1" ] ; then
79 echo -n "CCCC" > $DEVICE
82 9) if [ "$3" -eq 0 ]; then
83 echo -n "[avr_evtd]: Disk usage now safe"
85 echo -n "[avr_evtd]: Disk used $3% > Monitored $DISKCHECK%"
87 E
) echo -n "[avr_evtd]: EM mode selected"
89 F
) echo -n "[avr_evtd]: Fan failure detected"
90 if [ "$3" -eq 0 ]; then
91 logger
-p user.emerg
'AVR Detected fan fault'
93 if [ "$3" -eq 4 ]; then
94 # Illuminate relevant LED and wait for AVR halt message
95 echo -n "iiii" > $DEVICE
97 S
) if [ "$3" -gt 100 ]; then
98 MESSAGE
="System shutdown in less than 5 minutes"
100 MESSAGE
="Shutdown delayed by $3 minutes"
102 # Produce relevant message
103 logger
-p user.emerg
$MESSAGE ;;
104 D
) MESSAGE
="[$3] Error with configuration file"
105 logger
-t $tag -p $facility $MESSAGE ;;