-
Notifications
You must be signed in to change notification settings - Fork 19
/
init
executable file
·57 lines (53 loc) · 1.15 KB
/
init
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
#!/bin/sh
### BEGIN INIT INFO
# Provides: omxd
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Raspberry Pi omxplayer playlist daemon and YouTube player
### END INIT INFO
omxd_pid() {
ps -C omxd -o pid=,ppid= | while read PID PPID; do
[ "$PPID" = 1 ] && echo $PID && break
done
}
start() {
if [ `omxd_pid` ]; then
echo '[info] Service omxd already running' >&2
return 0
fi
echo -n '[....] Starting omxd playlist daemon... ' >&2
omxd >/dev/null
echo "done.\r[ ok ]" >&2
}
stop() {
PID=`omxd_pid`
if [ -z "$PID" ]; then
echo '[info] Service omxd not running' >&2
return 0
fi
echo -n '[....] Stopping omxd playlist daemon... ' >&2
kill $PID >/dev/null 2>&1
killall omxplayer.bin >/dev/null 2>&1
rm -f /var/run/omxctl /var/log/omxlog* /var/log/omxstat /var/log/omxplayer.log.* >/dev/null 2>&1
echo "done.\r[ ok ]" >&2
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
force-reload)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}"
esac