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

depend() {
	after localmount
}

check_key() {
	[ -s "${KEYFILE}" ] && return 0
	dd if=/dev/urandom bs=1 count=1024 >/etc/munge/munge.key 2>/dev/null || return 1
	chown munge:munge "${KEYFILE}" || return 1
	chmod 700 "${KEYFILE}" || return 1
}

start() {
	ebegin "Starting munged"
	if ! check_key; then
		eerror "Failed to verify/create munge key"
		eend 1 && exit 1
	fi
	checkpath -d -m 755 -o munge:munge /var/run/munge
	checkpath -d -m 711 -o munge:munge /var/lib/munge
	checkpath -d -m 700 -o munge:munge /var/log/munge
	start-stop-daemon -S /usr/sbin/munged \
		--user munge \
		--group munge \
		--pidfile /var/run/munge/munged.pid \
		-- \
		--key-file="${KEYFILE}" \
		--group-check-mtime="${GROUP_CHECK_MTIME}" \
		--group-update-time="${GROUP_UPDATE_TIME}" \
		--num-threads="${NUM_THREADS}"
	eend ${?}
}

stop() {
	ebegin "Stopping munged"
	start-stop-daemon -K /usr/sbin/munged \
		--pidfile /var/run/munge/munged.pid
	eend ${?}
}