Quoting Don Armstrong <[EMAIL PROTECTED]>:
Yeah, this doesn't apply to directories though. Anyway, it's
reasonable to change, but I'm going to directly parse the -d option
out of OPTIONS because otherwise I'll break anyone who has already
configured a separate -d using the OPTIONS configuration that I
already support.
Yes, you are right, if a user specify -P pidfile or -p socketfile,
then the startup script should work correctly. Now i have another
suggestion:
--- spamass-milter.ORIG 2006-06-16 14:21:27.000000000 +0200
+++ spamass-milter 2006-06-16 14:21:05.000000000 +0200
@@ -33,8 +33,8 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/spamass-milter
-SOCKET=/var/run/sendmail/spamass.sock
-PIDFILE=/var/run/spamass.pid
+SOCKET=/var/run/spamass-milter/spamass.sock
+PIDFILE=/var/run/spamass-milter/spamass.pid
DESC="Sendmail milter plugin for SpamAssassin"
DEFAULT=/etc/default/spamass-milter
@@ -47,11 +47,19 @@
fi;
set -e
+# Check, if Socket or Pidfile specified in OPTIONS
+SOCKETSPEC=`echo $OPTIONS | perl -ne 'print "$1\n" if $_ =~
/-p\s+(\S+)\b/;'`
+PIDFILESPEC=`echo $OPTIONS | perl -ne 'print "$1\n" if $_ =~
/-P\s+(\S+)\b/;'`
+[ -n "$SOCKETSPEC" ] && SOCKET="$SOCKETSPEC"
+[ -n "$PIDFILESPEC" ] && PIDFILE="$PIDFILESPEC"
case "$1" in
start)
echo -n "Starting $DESC: "
+ [ ! -d "`dirname $SOCKET`" ] && mkdir "`dirname $SOCKET`"
+ [ ! -d "`dirname $PIDFILE`" ] && mkdir "`dirname $PIDFILE`"
+
start-stop-daemon --start -p $PIDFILE --exec $DAEMON -- -P
$PIDFILE -f -p $SOCKET $OPTIONS
echo "${DAEMON}"
This should handle the following situations:
- The new default place in /var/run moved from /var/run/sendmail to
/var/run/spamass-milter for pidfile and socketfile
- Avoid conflicts with sendmail, which creates /var/run/sendmail
and set the owner and permissions, if the directory is not available
- The user can specifiy SOCKET of PIDFILE in /etc/default/spamass-milter
- The user can specifiy the options -p and -P in OPTIONS
- The options in OPTIONS has the highest priority
Thanks to Stephen Gran, who points out the dirname function.
Best regards
Herbert Straub