summaryrefslogtreecommitdiff
path: root/recipes/avr-evtd/files/init
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
committerDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
commit709c4d66e0b107ca606941b988bad717c0b45d9b (patch)
tree37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/avr-evtd/files/init
parentfa6cd5a3b993f16c27de4ff82b42684516d433ba (diff)
rename packages/ to recipes/ per earlier agreement
See links below for more details: http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326 http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816 Signed-off-by: Denys Dmytriyenko <denis@denix.org> Acked-by: Mike Westerhof <mwester@dls.net> Acked-by: Philip Balister <philip@balister.org> Acked-by: Khem Raj <raj.khem@gmail.com> Acked-by: Marcin Juszkiewicz <hrw@openembedded.org> Acked-by: Koen Kooi <koen@openembedded.org> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/avr-evtd/files/init')
-rwxr-xr-xrecipes/avr-evtd/files/init124
1 files changed, 124 insertions, 0 deletions
diff --git a/recipes/avr-evtd/files/init b/recipes/avr-evtd/files/init
new file mode 100755
index 0000000000..34ea528926
--- /dev/null
+++ b/recipes/avr-evtd/files/init
@@ -0,0 +1,124 @@
+#!/bin/sh
+#
+# avr_evtd Linkstation/Kuro AVR daemon
+#
+# Other files used are:
+# /etc/default/avr_evtd - Optional configuration file
+# /etc/avr_evtd/EventScript - Provides user with scripted
+# AVR event points
+# Optional files:
+# /etc/melco/timer_Sleep - Standard Melco sleep settings
+#
+# Written by Bob Perry (2006) lb-source@users.sourceforge.net
+#
+
+#
+# Location of the avr watchdog daemon and the init directory
+#
+DAEMON=/usr/sbin/avr_evtd
+initdir=/etc/init.d
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
+tag=linkstation
+facility=user.info
+
+test -e $DAEMON || exit 0
+
+getDevice()
+{
+ #
+ # Load custom settings
+ #
+ MIPS=NO
+
+ #
+ # Populate the configured settings
+ #
+ [ -f /etc/default/avr_evtd ] && . /etc/default/avr_evtd > /dev/null 2>&1
+
+ # Try and determine the UART used. The MIPS only has one UART
+ # available and the process is built accordingly. To support modified
+ # kernel's/kuro systems with polled over UARTs, drill into kernel
+ # configuration for the memory configuration of the UART to determine
+ # which tty to use if not set in the configuration file
+ uname -m | grep -q mips && MIPS=YES && DEVICE=/dev/ttyS0
+
+ if [ -z "$DEVICE" ] && [ "$MIPS" = "NO" ]
+ then
+ DEVICE=/dev/ttyS0
+ # Search for valid port address
+ PORT_ADDRESS=`$DAEMON -i -d /dev/ttyS1`
+ if [ $PORT_ADDRESS -eq 80004500 ] ; then DEVICE=/dev/ttyS1 ; fi
+ fi
+}
+
+start()
+{
+ #
+ # Daemon options
+ # e.g -d /dev/ttyS1
+ #
+ daemonoptions=
+
+ CONSOLE=OFF
+
+ getDevice
+
+ # Establish daemon startup options based on configuration settings
+ if [ "$EMMODE" = "YES" ]; then daemonoptions=-e ; fi
+
+ if [ -n "$DEVICE" ] && [ "$MIPS" = "NO" ]
+ then
+ [ -n "$daemonoptions" ] && daemonoptions="$daemonoptions "
+ daemonoptions="$daemonoptions-d $DEVICE"
+ fi
+
+ # Is this a MIPSEL box?
+ if [ "$MIPS" = "YES" ]
+ then
+ if [ -e /proc/linkstation ]
+ then
+ # Determine if console ttyS0 is in-use
+ CONSOLE=`cat /proc/linkstation | grep CONSOLE | awk -F "=" '{print $2}'`
+ fi
+ fi
+
+ if [ "$CONSOLE" = "ON" ]
+ then
+ echo "[avr_evtd]: Not started services as console in-use"
+ logger -t $tag -p $facility 'Not started avr_evtd as kernel still has console'
+ else
+ echo "Start services: avr_evtd"
+ /sbin/start-stop-daemon --start --quiet --exec $DAEMON -- $daemonoptions
+ logger -t $tag -p $facility 'Started daemon avr_evtd'
+ fi
+}
+
+stop()
+{
+ echo "Stop services: avr_evtd"
+ /sbin/start-stop-daemon --stop --quiet --exec $DAEMON
+ logger -t $tag -p $facility 'Stopped daemon avr_evtd'
+}
+
+# Check request
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ sleep 1
+ start
+ ;;
+ *)
+ echo "Usage: $DAEMON {start|stop|restart}" >&2
+ ;;
+esac
+
+exit 0
+
+