#!/bin/sh # description: start/stop sendmail milter plugin milter-regex # # default: S/K40 0/K40 1/K40 2/S87 . /lib/svc/share/smf_include.sh # ACCOUNT, under which the milter should run ACCOUNT=smmsp # configuration file CONF=/etc/mail/milter-regex.conf SOCKET=`/usr/bin/svcprop -p config/socket $SMF_FMRI 2>/dev/null` if [ -z "$LOCALNETS" -o '""' = "$LOCALNETS" ]; then SOCKET="local:/var/milter/milter-regex.sock" fi # If "yes", log verbose to syslog with mail.debug # Make sure, you have a lot of space on your logging device, when enabling # this option !!! VERBOSE=`/usr/bin/svcprop -p config/debug $SMF_FMRI 2>/dev/null` if [ "$VERBOSE" = "true" ]; then VERBOSE="-d" else VERBOSE="" fi # a comma separatad list of local networks: always accept mails from its # clients without scanning LOCALNETS=`/usr/bin/svcprop -p config/local $SMF_FMRI 2>/dev/null` if [ -z "$LOCALNETS" -o '""' = "$LOCALNETS" ]; then LOCALNETS="" else LOCALNETS="-l $LOCALNETS" fi # quarantine rejected messages QUARANTINE=`/usr/bin/svcprop -p config/quarantine $SMF_FMRI 2>/dev/null` if [ "$QUARANTINE" = "true" ]; then QUARANTINE='-q' else QUARANTINE="" fi # # no further changes should be required # MILTERDIR=@CLIENT_BASEDIR@ if [ ! -f ${CONF} ]; then echo "Missing config file $CONF" exit $SMF_EXIT_ERR_CONFIG fi ZN=`/sbin/zonename` if [ "$ZN" = "global" ]; then ZPPID=1 else ZPPID=`pgrep -x zsched 2>/dev/null` fi case "$1" in 'start') echo "Starting milter-regex sendmail filter ..." if [ ! -x ${MILTERDIR}/sbin/milter-regex ]; then echo "failed (unable to execute ${MILTERDIR}/sbin/milter-regex)." exit $SMF_EXIT_ERR_FATAL fi PIDS=`pgrep -x -u $ACCOUNT -P $ZPPID milter-regex` if [ -n "$PIDS" ]; then echo "is already running." exit $SMF_EXIT_OK fi ${MILTERDIR}/sbin/milter-regex -c $CONF $VERBOSE $LOCALNETS $QUARANTINE -p ${SOCKET} if [ $? -ne 0 ]; then echo "failed." exit $SMF_EXIT_ERR_FATAL fi echo "done." ;; 'stop') echo "Stopping milter-regex sendmail filter ..." pkill -9 -x -u $ACCOUNT -P $ZPPID milter-regex echo "done." ;; *) echo "Usage: $0 { start | stop }" exit $SMF_EXIT_ERR_FATAL ;; esac exit $SMF_EXIT_OK