summaryrefslogtreecommitdiff
blob: 74583857ad023b40b5759946df1a852dfb2f7b07 (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-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-auth/munge/files/munged.initd,v 1.1 2010/11/14 23:04:40 jsbronder Exp $

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