summaryrefslogtreecommitdiff
blob: 0260192c3ee145f2bd5d1b94200c10cdfa11e20c (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
#!/sbin/openrc-run
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

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 $?
}