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

depend() {
	use dns logger net
}

check_cfg() {
	if [ -z "${USER}" ] ; then
		eerror "USER is unset"
		return 1
	fi

	if [ ! -s "${CONFIG}" ]; then
		eerror "configuration file ${CONFIG} doesn't seem to be valid"
		return 1
	fi
}

start() {
	check_cfg || return 1

	# Remove stalled Unix socket if no other process is using it
	if [ -S "${SOCKET}" ] && ! fuser -s "${SOCKET}"; then
		rm "${SOCKET}"
	fi
	
	ebegin "Starting milter-regex"
	start-stop-daemon --start --exec /usr/bin/milter-regex -- \
		-u "${USER}" -p "${SOCKET}" -c "${CONFIG}"
	EXIT=$?
	[ $? == 0 ] && chmod a+rw "${SOCKET}"
	eend ${EXIT}
}

stop() {
	ebegin "Stopping milter-regex"
	start-stop-daemon --stop --exec /usr/bin/milter-regex
	eend $?
}