pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: clamsmtpd started too early (pkg/36292)



Here's the patch for pkgsrc/mail/clamsmtp/files/clamsmtpd.sh I'd like
to commit...

Martti

Index: clamsmtpd.sh
===================================================================
RCS file: /cvsroot/pkgsrc/mail/clamsmtp/files/clamsmtpd.sh,v
retrieving revision 1.5
diff -u -r1.5 clamsmtpd.sh
--- clamsmtpd.sh        8 Oct 2005 08:56:48 -0000       1.5
+++ clamsmtpd.sh        29 May 2007 10:02:49 -0000
@@ -23,7 +23,7 @@
 fi

 name="clamsmtpd"
-rcvar=$name
+rcvar="${name}"
 command="@PREFIX@/sbin/${name}"
 pidfile="@VARBASE@/run/clamsmtpd.pid"

@@ -39,11 +39,34 @@
                        /^#/ {next}; /^User[    ]/ {r = $2};
                        END {print r}' ${clamav_conffile}`}
 else
+       : ${socket="/tmp/clamd"}
        : ${clamsmtpd_user="@CLAMAV_USER@"}
 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
        @TOUCH@ ${pidfile}
        @CHOWN@ ${clamsmtpd_user} ${pidfile}
 }
@@ -52,11 +75,11 @@
 {
        @ECHO@ "Starting ${name}."
        doit="${command} ${clamsmtpd_flags} -p ${pidfile}"
-       @SU@ -m ${clamsmtpd_user} -c "$doit"
+       @SU@ -m ${clamsmtpd_user} -c "${doit}"
 }

 if [ -f /etc/rc.subr -a -d /etc/rc.d -a -f /etc/rc.d/DAEMON ]; then
-       load_rc_config $name
+       load_rc_config ${name}
        run_rc_command "$1"
 else
        if [ -f /etc/rc.conf ]; then



Home | Main Index | Thread Index | Old Index