3 # avr_evtd Linkstation/Kuro AVR daemon
5 # Other files used are:
6 # /etc/default/avr_evtd - Optional configuration file
7 # /etc/avr_evtd/EventScript - Provides user with scripted
10 # /etc/melco/timer_Sleep - Standard Melco sleep settings
12 # Written by Bob Perry (2006) lb-source@users.sourceforge.net
16 # Location of the avr watchdog daemon and the init directory
18 DAEMON
=/usr
/sbin
/avr_evtd
21 PATH
=/sbin
:/bin
:/usr
/sbin
:/usr
/bin
:/usr
/local
/sbin
25 test -e $DAEMON ||
exit 0
30 # Load custom settings
35 # Populate the configured settings
37 [ -f /etc
/default
/avr_evtd
] && .
/etc
/default
/avr_evtd
> /dev
/null
2>&1
39 # Try and determine the UART used. The MIPS only has one UART
40 # available and the process is built accordingly. To support modified
41 # kernel's/kuro systems with polled over UARTs, drill into kernel
42 # configuration for the memory configuration of the UART to determine
43 # which tty to use if not set in the configuration file
44 uname
-m |
grep -q mips
&& MIPS
=YES
&& DEVICE
=/dev
/ttyS0
46 if [ -z "$DEVICE" ] && [ "$MIPS" = "NO" ]
49 # Search for valid port address
50 PORT_ADDRESS
=`$DAEMON -i -d /dev/ttyS1`
51 if [ $PORT_ADDRESS -eq 80004500 ] ; then DEVICE
=/dev
/ttyS1
; fi
67 # Establish daemon startup options based on configuration settings
68 if [ "$EMMODE" = "YES" ]; then daemonoptions
=-e ; fi
70 if [ -n "$DEVICE" ] && [ "$MIPS" = "NO" ]
72 [ -n "$daemonoptions" ] && daemonoptions
="$daemonoptions "
73 daemonoptions
="$daemonoptions-d $DEVICE"
76 # Is this a MIPSEL box?
77 if [ "$MIPS" = "YES" ]
79 if [ -e /proc
/linkstation
]
81 # Determine if console ttyS0 is in-use
82 CONSOLE
=`cat /proc/linkstation | grep CONSOLE | awk -F "=" '{print $2}'`
86 if [ "$CONSOLE" = "ON" ]
88 echo "[avr_evtd]: Not started services as console in-use"
89 logger
-t $tag -p $facility 'Not started avr_evtd as kernel still has console'
91 echo "Start services: avr_evtd"
92 /sbin
/start-stop-daemon
--start --quiet --exec $DAEMON -- $daemonoptions
93 logger
-t $tag -p $facility 'Started daemon avr_evtd'
99 echo "Stop services: avr_evtd"
100 /sbin
/start-stop-daemon
--stop --quiet --exec $DAEMON
101 logger
-t $tag -p $facility 'Stopped daemon avr_evtd'
118 echo "Usage: $DAEMON {start|stop|restart}" >&2