overlay/sys-apps/micro-evtd/files/micro-evtd.command
2011-12-13 16:38:57 +01:00

59 lines
1.1 KiB
Bash

#!/bin/sh
# Wrapper script for micro-evtd to execute single commands.
DAEMON_BASE=/usr/sbin/micro-evtd
MICROAPL="/usr/sbin/microapl -a"
PIDFILE=/var/run/micro-evtd.pid
# Test if device is supported
machine=`sed -n '/Hardware/ {s/^Hardware\s*:\s//;p}' /proc/cpuinfo`
case $machine in
"Buffalo Linkstation Pro/Live" | "Buffalo/Revogear Kurobox Pro")
DAEMON=$DAEMON_BASE.pro ;;
*)
DAEMON=$DAEMON_BASE.tera ;;
esac
micro-evtd_start() {
$DAEMON >/dev/null # daemon forks on its own
# Allow time to startup
sleep 1
pid=$(cat $PIDFILE)
if [ "$pid" ]; then
echo $pid
return 0
fi
return 1
}
# Execute commands here
case "$1" in
finish)
$MICROAPL led_set_blink power
$MICROAPL led_set_code_information 15
;;
init)
$MICROAPL led_set_blink 0
$MICROAPL bz_melody 30 b4 || true
;;
start)
# Start micro-evtd if not already running, exit with failure
# if start failed
[ -n "$(pidof micro-evtd)" ] || micro-evtd_start || exit 1
;;
startup)
$MICROAPL led_set_blink power
;;
stop)
kill -TERM $(cat $PIDFILE)
rm -f $PIDFILE
;;
*)
$DAEMON "$@"
;;
esac
exit 0