1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
#!/bin/sh
# Wrapper script for micro-evtd to execute single commands.
# If called with -t, it only tests if the device is supported.
DAEMON=/usr/sbin/micro-evtd
MICROAPL="/usr/sbin/microapl -a"
PIDFILE=/var/run/micro-evtd.pid
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
}
# Test if device is supported
machine=`sed -n '/Hardware/ {s/^Hardware\s*:\s//;p}' /proc/cpuinfo`
case $machine in
*"(Flattened Device Tree)")
machine=$(cat /proc/device-tree/model)
;;
esac
case $machine in
"Buffalo Linkstation Pro/Live" | "Buffalo/Revogear Kurobox Pro")
# Success or continue
[ "$1" = "-t" ] && exit 0 || true ;;
*)
# Failure Silently exit
[ "$1" = "-t" ] && exit 1 || exit 0 ;;
esac
# 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
;;
*)
;;
esac
exit 0
|