#!/bin/sh
+# amavisd-cn /etc/init.d/ initscript wrapper for CARNetized amavisd-new
+#
+# Start and stop Amavis, ClamAV and Postfix/Sendmail
+
+### BEGIN INIT INFO
+# Provides: amavisd-cn
+# Required-Start: $local_fs $remote_fs $syslog $named $network $time
+# Required-Stop: $local_fs $remote_fs $syslog $named $network
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: start and stop Amavis, ClamAV and Postfix/Sendmail
+# Description: wrapper for starting/stopping MTA and related services
+### END INIT INFO
+
set -e
# options for daemons:
options='
clamd clamav-daemon clamav /usr/sbin/clamd clamav/clamd.pid 5 clamav.log
amavis amavis.amavisd-new amavis amavisd \\(master\\) amavis/amavisd.pid 5 socket
-milter amavisd-new-milter amavis /usr/sbin/amavis-milter amavis/amavisd-new-milter.pid 5 socket
'
# note: pgrep -f takes a regexp, and this is shell expanded once, hence \\
IFS="$IFSOLD"
num=${num:-4}
sleep=${sleep:-1}
- maxtry=${maxtry:-10}
+ maxtry=${maxtry:-90}
if [ -n "$pidfile" ]; then
pidfile=/var/run/$pidfile
findpid="[ -f $pidfile ] && cat $pidfile || true"
do
sleep $sleep # 1st, give it a chance to run
pid=`eval $findpid` # 2nd: find it
- [ -z "$pid" ] && return 1 # not running at all
- count=`ls -1 /proc/$pid/fd 2>/dev/null| wc -l` # 3rd: count all it's worth
- [ "$count" -ge "$num" ] && ls -l /proc/$pid/fd | grep -q $fdname \
- && return # success -- release
+ if [ ! -z "$pid" ]; then
+ count=`ls -1 /proc/$pid/fd 2>/dev/null| wc -l` # 3rd: count all it's worth
+ [ "$count" -ge "$num" ] && ls -l /proc/$pid/fd | grep -q $fdname \
+ && return # success -- release
+ fi
try=$(($try+1))
[ "0$try" -ge "0$maxtry" ] && return 1 # no luck this time
done
# If there's no diversion, play possum
[ -x /etc/init.d/amavis.amavisd-new ] || exit 0
-if [ -x /etc/init.d/postfix -a -x /usr/lib/postfix/master ]; then
- mta=postfix
-else
- mta=sendmail
-fi
+mta=postfix
case "$arg" in
- start|stop|restart|reload|force-reload)
+ start|stop|restart|reload|force-reload|debug)
/etc/init.d/amavis.amavisd-new "$arg"
;;
istart)
start clamd
start amavis
- [ $mta = sendmail ] && start milter
- /etc/init.d/$mta start
+ if [ -x "/etc/init.d/$mta" ]; then
+ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+ invoke-rc.d $mta start
+ else
+ /etc/init.d/$mta start
+ fi
+ fi
;;
istop)
- /etc/init.d/$mta stop
- [ $mta = sendmail ] && stop milter
+ if [ -x "/etc/init.d/$mta" ]; then
+ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+ invoke-rc.d $mta stop
+ else
+ /etc/init.d/$mta stop
+ fi
+ fi
stop amavis
stop clamd
;;