summaryrefslogtreecommitdiff
blob: 675d1471da6266f2c886c0d6006b04ab3822af43 (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
38
39
40
#!/sbin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

NAME=${SVCNAME##*.}
if [ -n "${NAME}" -a "${SVCNAME}" != "samplicator" ]; then
    PID="/run/samplicator.${NAME}.pid"
    PNAME=$(echo ${RC_SVCNAME} | sed 's/\..*//g')
    CONF_DEFAULT="/etc/conf.d/samplicator.${NAME}"
else
    PID="/run/samplicator.pid"
    PNAME=${RC_SVCNAME}
    CONF_DEFAULT="/etc/conf.d/samplicator"
fi
CONF=${CONF:-${CONF_DEFAULT}}
EXEC=${EXEC:-/usr/bin/samplicate}

depend() {
        need net
        provide samplicator
}

start() {
        ebegin "Starting samplicator"
        start-stop-daemon --start --quiet --background --make-pidfile --pidfile ${PID} --exec ${EXEC} -- ${OPTS} ${CONFIG}
        eend $?
}

start_post() {
        pgrep -n $(echo ${PNAME} | sed 's/or/e/') > ${PID}
}

stop() {
        ebegin "Stopping samplicator"
        start-stop-daemon --stop --quiet --pidfile ${PID}
        rm -f ${PID}
        eend $?
}