1#!/sbin/runscript
2# $Header: /cvsroot/milter-greylist/rc-gentoo.sh.in,v 1.2 2010/02/15 16:38:04 manu Exp $Id
3
4# NB: Gentoo Config is in /etc/conf.d/milter-greylist
5
6opts="start stop restart status"
7
8# For a true ebuild the following variables should be put in
9#/etc/conf.d/milter-greylist
10NAME=milter-greylist
11DAEMON=/usr/local/bin/$NAME
12USER=@USER@
13# SOCKET should be the socket specified  in the MILTER definition sendmail.mc
14# INPUT_MAIL_FILTER(`greylist',`S=local:/var/milter-greylist/milter-greylist.sock')
15SOCKET=/var/$NAME/milter-greylist.sock
16PIDFILE="/var/$NAME/$NAME.pid"
17DOPTIONS="-p $SOCKET -u $USER -P $PIDFILE"
18
19depend() {
20	need net
21	use logger
22	before sendmail
23}
24
25start() {
26	ebegin "Starting $DESC"
27	start-stop-daemon --quiet --start --startas $DAEMON --pidfile $PIDFILE  -- $DOPTIONS
28	eend $? "Failed to start ${DAEMON}"
29}
30
31stop() {
32	ebegin "Stopping $DESC"
33	start-stop-daemon --stop --name $NAME
34	eend $? "Failed to stop ${DAEMON}"
35}
36
37restart() {
38	svc_stop
39	# needed to avoid potential mi_stop errors
40	sleep 4
41	svc_start
42	kill -HUP `head -n 1 /var/run/sendmail.pid`
43}
44
45