X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=debian%2Finit;h=b689825c36747181ec046cae7cc7c366a15c9e2a;hb=56293621f442f02c17dc4ca1711ae5cd2359f24e;hp=8af8212dfa618112f11ea1d90192909526fea5fc;hpb=1c3f285a0edf2971bb7fd75147e10bb66fb5323c;p=amavisd-cn.git diff --git a/debian/init b/debian/init index 8af8212..b689825 100755 --- a/debian/init +++ b/debian/init @@ -1,5 +1,21 @@ #!/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: @@ -7,7 +23,6 @@ set -e 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 \\ @@ -61,7 +76,7 @@ wait_for_fds () { 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" @@ -75,10 +90,11 @@ wait_for_fds () { 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 @@ -105,27 +121,21 @@ esac # 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 ;; istop) /etc/init.d/$mta stop - [ $mta = sendmail ] && stop milter stop amavis stop clamd ;;