forked from richardghirst/PiBits
-
Notifications
You must be signed in to change notification settings - Fork 5
/
init.sysv
executable file
·66 lines (60 loc) · 1.34 KB
/
init.sysv
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
66
#!/bin/sh
### BEGIN INIT INFO
# Provides: servoblaster
# Required-Start: hostname $local_fs
# Required-Stop:
# Should-Start:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop servod.
# Description: This script starts/stops servod.
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
. /lib/init/vars.sh
OPTS="--idle-timeout=2000"
# Customise as necessary, e.g.
#OPTS="--idle-timeout=1000 --p1pins=15,16,18,22 -s 5 -m 102 -x 444"
#STATUSFILE="/tmp/servoblaster-status"
STATUSFILE="/run/servoblaster.status"
if [ $( id -u ) != 0 ]; then
echo "ERROR: Must be run as root"
exit 1
fi
case "$1" in
start)
/usr/local/sbin/servod --daemonise=1 $OPTS >/dev/null
;;
restart|reload|force-reload)
killall servod
/usr/local/sbin/servod --daemonise=1 $OPTS >/dev/null
;;
stop)
killall servod
;;
status)
if [ ! -e /dev/servoblaster ]; then
echo "ERROR: /dev/servoblaster does not exist"
exit 2
fi
rm -f $STATUSFILE
echo "status $STATUSFILE" > /dev/servoblaster
sleep 0.2
if [ ! -e $STATUSFILE ]; then
echo "ERROR: servod not responding"
exit 3
elif grep -q "^OK" $STATUSFILE; then
echo "OK"
exit 0
elif grep "^ERROR:" $STATUSFILE; then
exit 4
else
echo "ERROR: No status from servod"
exit 5
fi
;;
*)
echo "Usage: servoblaster [start|stop|status]" >&2
exit 6
;;
esac
exit 0