summaryrefslogtreecommitdiff
blob: bcf41de8a7885643f5e9c08eadf9ed0c4811f511 (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
48
49
50
51
52
53
54
55
56
57
58
59
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/mail-mta/yacsd/files/yacsd.rc6.2.2.9,v 1.1 2006/03/07 21:07:20 ferdy Exp $

opts="${opts} configtest reload"

YACSD="${YACSD:-/usr/bin/yacsd}"
PIDFILE="${PIDFILE:-/var/run/yacsd.pid}"
YACSD_OPTS="${YACSD_OPTS:---config=/etc/yacs-0.6/yacsd.conf --pidfile=${PIDFILE}}"

depend() {
	need logger dns net mysql
}

checkconfig() {
	${YACSD} ${YACSD_OPTS} -t
	ret=$?
	if [ $ret -ne 0 ]; then
		eerror "yacsd has detected an error in configuration files."
	fi
	return $ret
}

configtest() {
	ebegin "Checking yacsd Configuration"
	checkconfig
	eend $?
}

start() {
	checkconfig || return $?

	ebegin "Starting yacsd"
	${YACSD} ${YACSD_OPTS} &>/dev/null
	eend $?
}

stop() {
	pid=$(cat ${PIDFILE})
	ebegin "Stopping yacsd (pid=${pid})"

	kill -TERM ${pid}

	for i in `seq 10`; do
		ps -C yacsd -o pid= | grep -q ${pid} && break
		sleep 1
	done

	ps -C yacsd -o pid= | grep -q ${pid}

	eend $?
}

reload() {
	ebegin "Reloading yacsd"
	kill -HUP $(cat ${PIDFILE})
	eend $?
}