File qmail.init.suse of Package qmail-toaster
#!/bin/sh
#
# SUSE system startup script for qmail mailserver service/daemon qmail
# Copyright (C) 2012 Johannes Weberhofer, Weberhofer GmbH, Austria
#
# This library is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or (at
# your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#
# /etc/init.d/qmail
# and its symbolic link
# /(usr/)sbin/rcqmail
#
# System startup script for qmail service
#
### BEGIN INIT INFO
# Provides: qmail MTA
# Required-Start: $syslog $named $network $remote_fs
# Required-Stop: $syslog $named $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: qmail daemon providing mail-server capabilities
# Description: Start qmail to allow sending of mails
### END INIT INFO
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
SVSCAN_BIN=/usr/bin/svscan
QMAIL_DIR=/var/qmail
QMAIL_SV_DIR=$QMAIL_DIR/supervise
test -x $SVSCAN_BIN || { echo "$SVSCAN_BIN not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
. /etc/rc.status
# Reset status of this service
rc_reset
case "$1" in
start)
echo -n "Starting qmail "
/sbin/startproc $SVSCAN_BIN "$QMAIL_SV_DIR"
rc_status -v
;;
stop)
echo -n "Shutting down qmail "
for DIR in $QMAIL_SV_DIR/* ; do
/usr/bin/svok "$DIR"
if [ $? == 0 ] ; then
/usr/bin/svc -dx "$DIR"
fi
if [ -d "$DIR/log" ] ; then
/usr/bin/svok "$DIR/log"
if [ $? == 0 ] ; then
/usr/bin/svc -dx "$DIR/log"
fi
fi
done
/sbin/killproc $SVSCAN_BIN
rc_status -v
;;
try-restart|condrestart)
if test "$1" = "condrestart"; then
echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}"
fi
$0 status
if test $? = 0; then
$0 restart
else
rc_reset # Not running is not a failure.
fi
# Remember status and be quiet
rc_status
;;
restart)
$0 stop
$0 start
rc_status
;;
force-reload)
$0 reload
rc_status -v
;;
reload)
echo -n "Reload service qmail "
for DIR in $QMAIL_SV_DIR/* ; do
/usr/bin/svc -hu "$DIR"
if [ -d "$DIR/log" ] ; then
/usr/bin/svc -hu "$DIR/log"
fi
done
rc_status -v
;;
status)
svstat $QMAIL_SV_DIR/* $QMAIL_SV_DIR/*/log
echo -n "Checking for service qmail "
/sbin/checkproc $SVSCAN_BIN
rc_status -v
;;
probe)
test /etc/tcprules.d/tcp.smtp.cdb -nt /var/run/qmail.pid && echo reload
;;
doqueue|alrm)
echo "Sending ALRM signal to qmail-send."
svc -a $QMAIL_DIR/supervise/send
;;
queue)
echo "Mail-queue statistics"
$QMAIL_DIR/bin/qmail-qstat
$QMAIL_DIR/bin/qmail-qread
;;
pause)
echo "Stop mail-services"
svc -p $QMAIL_DIR/supervise/send
svc -p $QMAIL_DIR/supervise/smtp
;;
cont)
echo "Continue mail services"
svc -c $QMAIL_DIR/supervise/send
svc -c $QMAIL_DIR/supervise/smtp
;;
cdb)
echo "Rebuild compiled confgurations"
tcprules /etc/tcprules.d/tcp.smtp.cdb /etc/tcprules.d/tcp.smtp.tmp < /etc/tcprules.d/tcp.smtp
chmod 644 /etc/tcprules.d/tcp.smtp*
if [ -f $QMAIL_DIR/bin/qmail-badmimetypes ] ; then
$QMAIL_DIR/bin/qmail-badmimetypes;
fi
if [ -f $QMAIL_DIR/bin/qmail-badloadertypes ] ; then
$QMAIL_DIR/bin/qmail-badloadertypes;
fi
if [ -f $QMAIL_DIR/bin/simscanmk ] ; then
$QMAIL_DIR/bin/simscanmk -g >/dev/null 2>&1;
if [ -f $QMAIL_DIR/control/simcontrol ] ; then
$QMAIL_DIR/bin/simscanmk >/dev/null 2>&1;
fi
fi
$0 reload
;;
*)
echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload|probe|doqueue|queue|pause|cont|cdb}"
echo "Special features:"
echo " pause temporarily stops mail service (connections accepted, nothing leaves)"
echo " cont continues paused mail service"
echo " cdb rebuild the tcpserver cdb file for smtp and reload all services"
echo " doqueue sends qmail-send ALRM, scheduling queued messages for delivery"
echo " reload ends qmail-send HUP, rereading locals and virtualdomains"
echo " queue shows status of queue"
exit 1
;;
esac
rc_exit