summaryrefslogtreecommitdiff
blob: 2fce2ae94a5ce2a61ad8b74a1d12e766d9831c51 (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$

USER="${USER:-nobody}"
PIDFILE="${PIDFILE:-/var/run/nutcracker.pid}"
NUTCRACKER_BIN="${NUTCRACKER_BIN:-/usr/bin/nutcracker}"
CONF_FILE="${CONF_FILE:-/etc/nutcracker/nutcracker.yml}"

depend() {
    need net
}

checkconf() {
	ebegin "Testing configuration"
	${NUTCRACKER_BIN} --test-conf \
		--conf-file=${CONF_FILE} \
		>/dev/null 2>&1
	eend $?
}

start() {
	checkconf || exit 1
        ebegin "Starting Nutcracker"
        start-stop-daemon --start -u ${USER} \
		--name ${SVCNAME} \
                --exec ${NUTCRACKER_BIN} -- \
		--conf-file="${CONF_FILE}" \
                --pid-file=${PIDFILE} \
		${NUTCRACKER_OPTS}
        eend $?
}

stop() {
        ebegin "Stopping Nutcracker"
        start-stop-daemon --stop --pidfile "${PIDFILE}"
        eend $?
}