solaris init.d

Derrick Georgiades dgeorgiades at POWERENG.COM
Wed May 14 15:56:05 IST 2003


I use these two on Solaris 9 on sparc.

Derrick Georgiades
POWER Engineers, Inc.


-----Original Message-----
From: David Lee [mailto:t.d.lee at DURHAM.AC.UK]
Sent: Wednesday, May 14, 2003 8:04 AM
To: MAILSCANNER at JISCMAIL.AC.UK
Subject: Re: solaris init.d


On Tue, 13 May 2003, Rob V wrote:

> Does anyone have a good sendmail+mailscanner init.d start/stop script for
> solaris?

Alas, it is somewhat less straightforward than that.  Solaris' own
sendmail "init.d" and its attendant "/etc/default/sendmail" change from
release to release (e.g. from Solaris 8 to Solaris 9).  So it is better to
edit what they give you on that machine, rather than import a complete,
but probably wrong and potentially harmful, script from a repository.

Now what MIGHT be worth exploring is whether the MailScanner distribution
could include a little Solaris script that would determine the Solaris
release and attempt to apply a relevant patch/diff to the "init.d" for
that particular release.

Naturally, a similar model might be applicable to the various releases of
other OSes.  This might well be a job for the new "autoconf"-based stuff
being planned for MailScanner.  (Yes, I'm aware that, in general, autoconf
should, in general, be programmed for features, not OSes, but this might
be a valid exception.)


(Note to Julian:  You may recall that I contributed some autoconf stuff to
MailScanner several months ago.  If you wish to explore the OS-dependent
patching of "init.d" scripts, and to do so in an autoconf-driven way, then
I'll be happy to exchange ideas with you.)

--

:  David Lee                                I.T. Service          :
:  Systems Programmer                       Computer Centre       :
:                                           University of Durham  :
:  http://www.dur.ac.uk/t.d.lee/            South Road            :
:                                           Durham                :
:  Phone: +44 191 334 2752                  U.K.                  :

-------------- next part --------------
#!/sbin/sh
#
#
process=MailScanner
virusdir="/opt/MailScanner/bin"
config="/opt/MailScanner/etc/MailScanner.conf"
SERVER_PID_FILE="/queue/MailScanner/var/MailScanner.pid"
PID_CHECK=`/usr/bin/ps -e -o pid -o args |
     /usr/bin/fgrep $virusdir/$process |
     /usr/bin/grep -v grep |
     /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
case "$1" in
'start')
        if [ "$PID_CHECK" = "" ]; then
        PATH=${virusdir}:$PATH
        echo Starting virus scanner...
        $process $config
        else
        echo Running with pid $PID_CHECK
        fi
        ;;
'stop')
        [ -f $SERVER_PID_FILE ] && kill `head -1 $SERVER_PID_FILE`
        /usr/bin/pkill -x MailScanner
        ;;
*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac
exit 0
-------------- next part --------------
#!/sbin/sh
#
#ident  "@(#)sendmail   1.19    01/12/05 SMI"

ERRMSG1='WARNING: /var/mail is NFS-mounted without setting actimeo=0,'
ERRMSG2='this can cause mailbox locking and access problems.'
SERVER_PID_FILE="/var/run/sendmail.pid"
CLIENT_PID_FILE="/queue/sendmailqueue.pid"
DEFAULT_FILE="/etc/default/sendmail"
ALIASES_FILE="/etc/mail/aliases"

check_queue_interval_syntax()
{
        default="15m"
        if [ $# -lt 1 ]; then
                answer=$default
                return
        fi
        if echo $1 | egrep '^([0-9]*[1-9][0-9]*[smhdw])+$' >/dev/null 2>&1; then
                answer=$1
        else
                answer=$default
        fi
}

case "$1" in
'start')
        if [ -f /usr/lib/sendmail -a -f /etc/mail/sendmail.cf ]; then
                if [ ! -d /queue/mqueue ]; then
                        /usr/bin/mkdir -m 0750 /queue/mqueue
                        /usr/bin/chown root:bin /queue/mqueue
                fi
                if [ ! -f $ALIASES_FILE.db ] && [ ! -f $ALIASES_FILE.dir ] \
                    && [ ! -f $ALIASES_FILE.pag ]; then
                        /usr/sbin/newaliases
                fi
                MODE="-bd"
                OPTIONS="-ODeliveryMode=queueonly -OQueueDirectory=/queue/mqueue
.in"
                [ -f $DEFAULT_FILE ] && . $DEFAULT_FILE
                #
                # * MODE should be "-bd" or null (MODE= or MODE="") or
                #   left alone.  Anything else and you're on your own.
                # * QUEUEOPTION should be "p" or null (as above).
                # * [CLIENT]QUEUEINTERVAL should be set to some legal value;
                #   sanity checks are done below.
                # * [CLIENT]OPTIONS are catch-alls; set with care.
                #
                if [ -n "$QUEUEOPTION" -a "$QUEUEOPTION" != "p" ]; then
                        QUEUEOPTION=""
                fi
                if [ -z "$QUEUEOPTION" -o -n "$QUEUEINTERVAL" ]; then
                        check_queue_interval_syntax $QUEUEINTERVAL
                        QUEUEINTERVAL=$answer
                fi
                check_queue_interval_syntax $CLIENTQUEUEINTERVAL
                CLIENTQUEUEINTERVAL=$answer
                /usr/lib/sendmail $MODE $OPTIONS &
                /usr/lib/sendmail -q$QUEUEINTERVAL $CLIENTOPTIONS -OPidFile=$CLI
ENT_PID_FILE &
                #
                # ETRN_HOSTS should be of the form
                # "s1:c1.1,c1.2        s2:c2.1 s3:c3.1,c3.2,c3.3"
                # i.e., white-space separated groups of server:client where
                # client can be one or more comma-separated names; N.B. that
                # the :client part is optional; see etrn(1M) for details.
                # server is the name of the server to prod; a mail queue run
                # is requested for each client name.  This is comparable to
                # running "/usr/lib/sendmail -qRclient" on the host server.
                #
                # See RFC 1985 for more information.
                #
                for i in $ETRN_HOSTS; do
                        SERVER=`echo $i | /usr/bin/sed -e 's/:.*$//'`
                        CLIENTS=`echo $i | /usr/bin/sed -n -e 's/,/ /g' \
                            -e '/:/s/^.*://p'`
                        /usr/sbin/etrn $SERVER $CLIENTS >/dev/null 2>&1 &
                done
        fi

        if /usr/bin/nawk 'BEGIN{s = 1}
            $2 == "/var/mail" && $3 == "nfs" && $4 !~ /actimeo=0/ &&
            $4 !~ /noac/{s = 0} END{exit s}' /etc/mnttab; then

                /usr/bin/logger -p mail.crit "$ERRMSG1"
                /usr/bin/logger -p mail.crit "$ERRMSG2"
        fi
        ;;

'stop')
        [ -f $SERVER_PID_FILE ] && kill `head -1 $SERVER_PID_FILE`
        if [ -f $CLIENT_PID_FILE ]; then
                kill `head -1 $CLIENT_PID_FILE`
                rm -f $CLIENT_PID_FILE
        fi
        /usr/bin/pkill -x -u 0 sendmail
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac
exit 0


More information about the MailScanner mailing list