summaryrefslogtreecommitdiff
blob: 4137774964d27ce6324b6e12464b3a1556079e25 (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
41
42
43
44
45
46
47
#!/sbin/openrc-run
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

DAEMON=/usr/sbin/bitflu.pl
PIDDIR=/var/run/bitflu
PIDFILE=${PIDDIR}/bitflu.pid
CONFFILE=/etc/bitflu/bitflu.config

depend() {
	need net
}

checkconfig() {
	if [ ! -f ${CONFFILE} ]; then
		eerror "No config file ${CONFFILE}"
		return 1
	fi

	if [ ! -d ${PIDDIR} ] && ! mkdir -p ${PIDDIR}; then
		eerror "Failed to create ${PIDDIR}"
		return 1
	fi

	chown bitflu:bitflu ${PIDDIR}
}

start() {
	checkconfig || return 1
	ebegin "Starting bitflu"
	start-stop-daemon --start --pidfile "${PIDFILE}" --user bitflu:bitflu \
		--exec "${DAEMON}" -- --config="${CONFFILE}" --daemon -q >/dev/null 2>&1
	eend $?
}

stop() {
	ebegin "Stoping bitflu"
	start-stop-daemon --stop --pidfile "${PIDFILE}" --exec "${DAEMON}"
	eend $?
}

restart() {
	svc_stop
	sleep 2
	svc_start
}