#!/bin/bash # Copyright (c) 2001 nexxium interactive GmbH, Kaarst (Germany) # Author: Sebastian Wolfgarten # visit www.wolfgarten.com! # Provides: start of qmail and vpopmail # let's use rc.config . /etc/rc.config # some variables QMAILHOME=/var/qmail VPOPMAILHOME=/home/vpopmail # which userid has user qmaild? USERID=`cat /etc/passwd | grep qmaild | awk -F: '{print $3}'` GROUPID=`cat /etc/group | grep nofiles | awk -F: '{print $3}'` FQDN=`cat /etc/rc.config | grep FQHOSTNAME= | awk -F= '{print $2}' | sed 's/"//g'` # which runlevels? base=${0##*/} link=${base#*[SK][0-9][0-9]} # force execution if not called by a runlevel directory test $link = $base && START_VQMAIL="yes" test "$START_VQMAIL" = yes || exit 0 # does the start script for qmail itself exist? QMAIL_BIN=/var/qmail/rc test -x $QMAIL_BIN || exit 5 rc_reset # does the start script for vpopmail exist? VPOPMAIL_BIN=/usr/local/bin/tcpserver test -x $VPOPMAIL_BIN || exit 5 rc_reset # here's what we tell the audience when we have # successfully started a service, see rc.config for more details return=$rc_done # okay baby, here's the main part. case "$1" in start) echo -n "Starting qmail and vpopmail" # Start the program files startproc $QMAIL_BIN startproc $VPOPMAIL_BIN -u $USERID -g $GROUPID -x $VPOPMAILHOME/etc/tcp.smtp.cdb 0 smtp $QMAILHOME/bin/qmail-smtpd & startproc $VPOPMAIL_BIN -H -R 0 pop3 $QMAILHOME/bin/qmail-popup $FQDN $VPOPMAILHOME/bin/vchkpw $QMAILHOME/bin/qmail-pop3d Maildir # remember the status and be verbose rc_status -v ;; stop) echo -n "Shutting down qmail and vpopmail" # kill it killall -TERM qmail-send killall -TERM tcpserver rc_status -v ;; restart) $0 stop $0 start rc_status ;; *) echo "Usage: $0 {start|stop}"; exit 1 esac rc_exit