summaryrefslogtreecommitdiff
path: root/recipes/piccontrol/files/init
blob: 3f2e51118381149fd70059a87aec6612df52f7eb (plain)
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
#! /bin/sh
# piccontrol - simple init.d piccontrol script - tim.ellis@foonas.org
set -e

if [ ! -f /usr/sbin/piccontrol ]; then
    echo -n "Warning: piccontrol binary not found. Shutting down"
    shutdown -h now
    exit -1
fi

case "$1" in
  start)
        echo -n "Starting piccontrol: "
        rm -f /var/run/piccontrol.sock
        start-stop-daemon -S -b -n piccontrol -a /usr/sbin/piccontrol -- -d
        sleep 1
        piccontrol statusled greenon
        piccontrol powerled on
        piccontrol buzzer short
        echo "done"
        ;;
  stop)
        echo -n "Stopping piccontrol: "
        start-stop-daemon -K -n piccontrol >&- 2>&- &
        echo "done"
        ;;
  restart)
        $0 stop
        $0 start
        ;;
  *)
        echo "Usage: piccontrol { start | stop | restart }" >&2
        exit 1
        ;;
esac

exit 0