Matt Sergeant wrote:
Does anyone have an rc script for qpsmtpd that we could include in the distro? I'm sure lots of people won't want to start it via daemontools.

We (SMEServer) have single RC script called "daemontools" and we symlink all of our daemontools/runit processes to that. All daemon specific startup is in the run scripts. Anyway, attached.

I have also attached qpsmtpd.run and sqpsmtpd.run

Gordon
#!/bin/sh

###########################################################################
#
# System V style init script.
# Relies on runit utilities to do the real work.
# It is assumed that init scripts will be linked to this script.
#
###########################################################################

# Determine the service name and its service directory from $0

SERVICE=$(/bin/basename $0 | sed -e 's/^[SK][0-9][0-9]*//')
SERVICE_DIR=/service/$SERVICE

###########################################################################

# Source in the RedHat initscripts functions

. /etc/rc.d/init.d/functions

# The maximum amount of time to wait for a process to shut down, in seconds.
WAITMAX=60

start()
{
    /bin/echo -n "Starting $SERVICE:"
    dirs=$1
    if [ -d $1/log ]; then
        dirs="$1/log $1"
    fi
    /usr/bin/runsvctrl u $dirs
    if [ $? -ne 0 ]; then
        failure "Starting $SERVICE"
    else
        success "Starting $SERVICE"
    fi
    /bin/echo
}

status()
{
    /usr/bin/runsvstat $1
}

stop()
{
    /bin/echo -n "Stopping $SERVICE:"
    /usr/bin/svwaitdown -t $WAITMAX $1
    if [ $? -ne 0 ]; then
        failure "Stopping $SERVICE"
    else
        success "Stopping $SERVICE"
    fi
    /bin/echo
}

# This function not only shuts the service down, but removes the /service
# symlink and shuts down the logger. This should only be used during an
# uninstall of the service in question.
svdisable()
{
    /bin/echo -n "Disabling $SERVICE:"
    stop $1
    cd $1 && rm -f $1
    dirs=.
    if [ -e log ]; then
        dirs="$dirs ./log"
    fi
    /usr/bin/runsvctrl d $dirs
    /usr/bin/runsvctrl x $dirs
    if [ $? -ne 0 ]; then
        failure "Disabling $SERVICE"
    else
        success "Disabling $SERVICE"
    fi
    /bin/echo
}

case $1 in

    restart)
        action "Restarting $SERVICE" /usr/bin/runsvctrl t $SERVICE_DIR
        /usr/bin/runsvctrl u $SERVICE_DIR
            ;;

    sigalrm)
        action "Sending ALRM signal to $SERVICE" /usr/bin/runsvctrl a 
$SERVICE_DIR
            ;;

    sigcont)
        action "Sending CONT signal to $SERVICE" /usr/bin/runsvctrl c 
$SERVICE_DIR
            ;;

    sighup)
        action "Sending HUP signal to $SERVICE" /usr/bin/runsvctrl h 
$SERVICE_DIR
            ;;

    sigusr1)
        action "Sending USR1 signal to $SERVICE" /usr/bin/runsvctrl 1 
$SERVICE_DIR
            ;;

    sigusr2)
        action "Sending USR2 signal to $SERVICE" /usr/bin/runsvctrl 2 
$SERVICE_DIR
            ;;

    sigint)
        action "Sending INT signal to $SERVICE" /usr/bin/runsvctrl i 
$SERVICE_DIR
            ;;

    sigkill)
        action "Sending KILL signal to $SERVICE" /usr/bin/runsvctrl k 
$SERVICE_DIR
            ;;

    sigstop)
        action "Sending STOP signal to $SERVICE" /usr/bin/runsvctrl p 
$SERVICE_DIR
            ;;

    sigterm)
        action "Sending TERM signal to $SERVICE" /usr/bin/runsvctrl t 
$SERVICE_DIR
            ;;

    status)
        /usr/bin/runsvstat $SERVICE_DIR
            ;;

    start)
        start $SERVICE_DIR
            ;;

    stop)
        stop $SERVICE_DIR
            ;;

    svdisable)
        svdisable $SERVICE_DIR
            ;;

    *)
        echo "usage: $0 
{start|stop|restart|status|sigalrm|sigcont|sighup|sigint|sigkill|sigstop|sigterm|sigusr1|sigusr2|svdisable}"
        ;;

esac
#!/bin/sh
#----------------------------------------------------------------------
# copyright (C) 1999-2005 Mitel Networks Corporation
# Copyright (C) 2005 Gordon Rowell <[EMAIL PROTECTED]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
#
# Technical support for this program is available from Mitel Networks
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------

[ -f ./runenv ] && . ./runenv

exec /usr/local/bin/softlimit -m 25000000 \
  ./qpsmtpd-forkserver \
        -u qpsmtpd \
        -l 0.0.0.0 \
        -p ${PORT:-25} \
        -c ${INSTANCES:-40} \
        -m ${INSTANCES_PER_IP:-5} \
        2>&1

#sub usage {
#        print <<"EOT";
#usage: qpsmtpd-forkserver [ options ]
# -l, --listen-address addr : listen on a specific address; default 0.0.0.0
# -p, --port P              : listen on a specific port; default 2525
# -c, --limit-connections N : limit concurrent connections to N; default 15
# -u, --user U              : run as a particular user (defualt 'smtpd')
# -m, --max-from-ip M       : limit connections from a single IP; default 5
#EOT
#        exit 0;
#}
#
#!/bin/sh
#----------------------------------------------------------------------
# copyright (C) 1999-2003 Mitel Networks Corporation
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#         
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#         
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
# 
# Technical support for this program is available from Mitel Networks 
# Please visit our web site www.mitel.com/sme/ for details.
#----------------------------------------------------------------------

[ -f ./runenv ] && . ./runenv

exec 2>&1
exec /usr/bin/tcpsvd \
    -v \
    -i ../qpsmtpd/peers \
    -c ${INSTANCES:-10} \
    -C ${INSTANCES_PER_IP:-5}:'421 per host concurrency limit reached\r\n' \
    -l ${TCPLOCALHOST:-0} \
    ${LISTENIP:-0} \
    ${PORT:-465} \
    ./sqpsmtpd

Reply via email to