summaryrefslogtreecommitdiff
blob: 409570d441ba66c11cef32428a2b2529775b5e7c (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
#!/sbin/runscript
# Copyright 1999-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/munin/files/munin-node_init.d_1.4.6-r2,v 1.1 2011/08/17 15:45:54 darkside Exp $

get_munin_config() {
	awk '$1 == "'$1'" { s=$2 } END { print s }' "$CFGFILE"
}

: ${NAME:="munin-node"}
: ${CFGFILE:=/etc/munin/munin-node.conf}
: ${PIDFILE:=$(get_munin_config pid_file)}
: ${NICE_LEVEL:=0}

depend() {
	config "$CFGFILE"

	need net
	before cron

	[ "$(get_munin_config log_file)" == "Sys::Syslog" ] && \
		use logger
}

start() {
	local piddir=$(dirname ${PIDFILE})
	[ -d ${piddir} ] || mkdir -p ${piddir}

	ebegin "Starting $NAME"
	start-stop-daemon --nicelevel $NICE_LEVEL --start --pidfile $PIDFILE --exec /usr/sbin/$NAME -- \
		--config "$CFGFILE"
	eend $?
}

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

# vim: filetype=gentoo-init-d: