libtool-cross 2.2.6[ab]: Drop legacy staging, taken from poky
[openembedded.git] / recipes / avr-evtd / files / init
blob34ea52892663f78f1c068605aea10275db677206
1 #!/bin/sh
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
8 # AVR event points
9 # Optional files:
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
19 initdir=/etc/init.d
21 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
22 tag=linkstation
23 facility=user.info
25 test -e $DAEMON || exit 0
27 getDevice()
30 # Load custom settings
32 MIPS=NO
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" ]
47 then
48 DEVICE=/dev/ttyS0
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
55 start()
58 # Daemon options
59 # e.g -d /dev/ttyS1
61 daemonoptions=
63 CONSOLE=OFF
65 getDevice
67 # Establish daemon startup options based on configuration settings
68 if [ "$EMMODE" = "YES" ]; then daemonoptions=-e ; fi
70 if [ -n "$DEVICE" ] && [ "$MIPS" = "NO" ]
71 then
72 [ -n "$daemonoptions" ] && daemonoptions="$daemonoptions "
73 daemonoptions="$daemonoptions-d $DEVICE"
76 # Is this a MIPSEL box?
77 if [ "$MIPS" = "YES" ]
78 then
79 if [ -e /proc/linkstation ]
80 then
81 # Determine if console ttyS0 is in-use
82 CONSOLE=`cat /proc/linkstation | grep CONSOLE | awk -F "=" '{print $2}'`
86 if [ "$CONSOLE" = "ON" ]
87 then
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'
90 else
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'
97 stop()
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'
104 # Check request
105 case "$1" in
106 start)
107 start
109 stop)
110 stop
112 restart)
113 stop
114 sleep 1
115 start
118 echo "Usage: $DAEMON {start|stop|restart}" >&2
120 esac
122 exit 0