Subject: Re: clamsmtpd started too early (pkg/36292)
To: None <pkgsrc-users@netbsd.org>
From: Martti Kuparinen <martti.kuparinen@iki.fi>
List: pkgsrc-users
Date: 05/29/2007 12:12:25
Hi,
As the new maintainer for clamsmtpd, I started to look at (my own)
pkg/36292. I'm running now the following patch on my servers and all
problems are gone.
Any objection for this change? Is it okay to use expr?
PS. On my secondary MX host it takes over 40 seconds for clamd to start.
This is a 2.8 GHz P4 with 2 GB RAM and only DNS and SMTP services
running...
Martti
--- /var/tmp/clamsmtpd 2007-05-29 10:46:13.000000000 +0300
+++ /etc/rc.d/clamsmtpd 2007-05-29 11:27:16.000000000 +0300
@@ -39,11 +39,34 @@
/^#/ {next}; /^User[ ]/ {r = $2};
END {print r}' ${clamav_conffile}`}
else
+ : ${socket="/tmp/clamd"}
: ${clamsmtpd_user="clamav"}
fi
clamsmtpd_prestart()
{
+ if [ ! -S "${socket}" ]; then
+ # Max wait time is 2 minutes
+ retries=11
+
+ echo -n "Waiting for clamd to become ready"
+ while [ ${retries} -gt 0 -a ! -S "${socket}" ]; do
+ echo -n "."
+ sleep 10
+ retries=`expr ${retries} - 1`
+ slow=true
+ done
+ if [ ! -S "${socket}" ]; then
+ echo ""
+ echo "ERROR: Unable to start clamsmtpd as clamd is not running!"
+ exit 1
+ fi
+
+ # Wait another 10 seconds so that clamd is really ready
+ echo -n "."
+ sleep 10
+ echo ""
+ fi
/usr/bin/touch ${pidfile}
/usr/sbin/chown ${clamsmtpd_user} ${pidfile}
}