/
ola.olad.init
65 lines (57 loc) · 1.76 KB
/
ola.olad.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
58
59
60
61
62
63
64
65
#!/bin/sh
### BEGIN INIT INFO
# Provides: olad
# Required-Start: $remote_fs $syslog $network
# Required-Stop: $remote_fs $syslog $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: OLA daemon
# Description: Open Lighting Architecture daemon
### END INIT INFO
PATH=/usr/local/bin:/bin:/usr/bin
NAME=olad
DAEMON=/usr/bin/$NAME
PIDFILE=/var/run/$NAME.pid
DESC="OLA daemon"
USER=olad
LOG_LEVEL=3
CONFIG_DIR="/var/lib/ola/conf"
# Reads config file (will override defaults above)
[ -r /etc/default/ola ] && . /etc/default/ola
if [ "$RUN_DAEMON" = "true" ] || [ "$RUN_DAEMON" = "yes" ] ; then
DAEMON_ARGS="--syslog --log-level $LOG_LEVEL --config-dir $CONFIG_DIR"
elif [ "$1" = "start" ] || [ "$1" = "stop" ] ; then
echo "The init script is currently inactive;\nuse \"dpkg-reconfigure ola\" to change this." >&2
fi
[ -x "$DAEMON" ] || exit 0
. /lib/lsb/init-functions
case "$1" in
start)
# master switch
if [ -n "$DAEMON_ARGS" ] ; then
log_daemon_msg "Starting $DESC" "$NAME"
/sbin/start-stop-daemon --start --background --make-pidfile --pidfile $PIDFILE --umask 0002 --chuid $USER --exec $DAEMON -- $DAEMON_ARGS
log_end_msg $?
fi
;;
stop)
# master switch
if [ "$RUN_DAEMON" = "true" ] || [ "$RUN_DAEMON" = "yes" ] ; then
log_daemon_msg "Stopping $DESC" "$NAME"
/sbin/start-stop-daemon --stop --pidfile $PIDFILE --chuid $USER --exec $DAEMON --retry 10
/bin/rm -f $PIDFILE
log_end_msg $?
fi
;;
reload|force-reload|restart)
$0 stop && $0 start
;;
status)
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|reload|restart|force-reload|status}" >&2
exit 1
;;
esac
exit 0