Below are Sys V style startup scripts for DBMail 1.x, which doesn't provide PID files. Starting in DBMail 2.0, startup scripts are provided in the contrib/ directory and make use of DBMail 2.0's PID file support. The startup scripts here were written and posted on the list originally, and I don't have records of who wrote them. If you read this, put your name in for credit.

Pay attention to the line that says 'dbmail-dir'. This may be different on your system and should be changed accordingly. Same with sed.

POP3 Daemon


#!/bin/sh
#
# chkconfig: 345 95 25
# description: dbmail pop3 daemon
#
# processname: dbmail-pop3d
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ ${NETWORKING} = "no" ] && exit 0


PS=/bin/ps
SED=/bin/sed
DBMAIL_DIR=/usr/local
POP3D=dbmail-pop3d

if ! echo "$PATH" | grep -q "$DBMAIL_DIR" ; then
  export PATH=$PATH:$DBMAIL_DIR/bin:$DBMAIL_DIR/sbin
fi

# Get current user name
getuser () {
    user=
    if [ -x /usr/bin/id ]
    then
       user=`/usr/bin/id -u -n`
    fi
}


# main program
getuser
if [ -n "$user" ]
then
    if [ "$user" != "root" ]
    then
       echo "Only root can run this command"; exit 0
    fi
else
    echo "Can't obtain user name"; exit 0
fi

case $1 in
'start')
	pid=`pidof $POP3D`
	if [ -n "$pid" ]
	then
	   echo "dbmail pop daemon is already running, PID $pid"
	else
	   $POP3D &
	   pid=`pidof $POP3D`
	   if [ -n "$pid" ]
	   then
	      echo "dbmail pop daemon started, PID $pid"
	   else
	      echo "Can't start dbmail pop daemon client"
	   fi
	fi
	;;
'stop') 

	pid=`pidof $POP3D`
	if [ -n "$pid" ]
	then
	   kill $pid
            sleep 4
	   pid=`pidof $POP3D`
            if [ -n "$pid" ]
            then
               echo "dbmail pop daemon not stopped, sending KILL..."
    	      kill -9 $pid
               sleep 5
	   	pid=`pidof $POP3D`
            fi
            if [ -n "$pid" ]
            then
               echo "dbmail pop daemon NOT stopped"
  	   else
	      echo "dbmail pop daemon stopped"
	   fi
	else
	   echo "dbmail pop daemon is not running"
	fi
	;;
'restart')
	$0 stop
	$0 start
	;;
'status')
	pid=`pidof $POP3D`
	if [ -n "$pid" ]
	then
		echo "dbmail pop daemon running, PID $pid"
	else
		echo "dbmail pop daemon stopped"
	fi
	;;
*)
	echo "Use $0 {start|stop|reload|status}";
	;;
esac

IMAP Daemon


#!/bin/sh
#
# chkconfig: 345 95 25
# description: dbmail imap daemon
#
# processname: dbmail-imapd
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ ${NETWORKING} = "no" ] && exit 0


PS=/bin/ps
SED=/bin/sed
DBMAIL_DIR=/usr/local
IMAPD=dbmail-imapd
DBMAIL_CONF=/etc/dbmail.conf

if ! echo "$PATH" | grep -q "$DBMAIL_DIR" ; then
  export PATH=$PATH:$DBMAIL_DIR/bin:$DBMAIL_DIR/sbin
fi

# Get current user name
getuser () {
    user=
    if [ -x /usr/bin/id ]
    then
       user=`/usr/bin/id -u -n`
    fi
}


# main program
getuser
if [ -n "$user" ]
then
    if [ "$user" != "root" ]
    then
       echo "Only root can run this command"; exit 0
    fi
else
    echo "Can't obtain user name"; exit 0
fi

case $1 in
'start')
	pid=`pidof $IMAPD`
	if [ -n "$pid" ]
	then
	   echo "dbmail imap daemon is already running, PID $pid"
	else
	   $IMAPD &
            pid=`pidof $IMAPD`
	   if [ -n "$pid" ]
	   then
	      echo "dbmail imap daemon started, PID $pid"
	   else
	      echo "Can't start dbmail imap daemon client"
	   fi
	fi
	;;
'stop') 

	pid=`pidof $IMAPD`
	if [ -n "$pid" ]
	then
	   kill $pid
            sleep 4
	   pid=`pidof $IMAPD`
            if [ -n "$pid" ]
            then
               echo "dbmail imap daemon not stopped, sending KILL..."
    	      kill -9 $pid
               sleep 5
	   	pid=`pidof $IMAPD`
            fi
            if [ -n "$pid" ]
            then
               echo "dbmail imap daemon NOT stopped"
  	   else
	      echo "dbmail imap daemon stopped"
	   fi
	else
	   echo "dbmail imap daemon is not running"
	fi
	;;
'restart')
	$0 stop
	$0 start
	;;
'status')
	pid=`pidof $IMAPD`
	if [ -n "$pid" ]
	then
		echo "dbmail imap daemon running, PID $pid"
	else
		echo "dbmail imap daemon stopped"
	fi
	;;
*)
	echo "Use $0 {start|stop|reload|status}";
	;;
esac

LMTPD Daemon


#!/bin/sh
#
# chkconfig: 345 95 25
# description: dbmail lmtpd daemon
#
# processname: dbmail-lmtpd
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ ${NETWORKING} = "no" ] && exit 0


PS=/bin/ps
SED=/bin/sed
DBMAIL_DIR=/usr/local
LMTPD=dbmail-lmtpd
DBMAIL_CONF=/etc/dbmail.conf

if ! echo "$PATH" | grep -q "$DBMAIL_DIR" ; then
  export PATH=$PATH:$DBMAIL_DIR/bin:$DBMAIL_DIR/sbin
fi

# Get current user name
getuser () {
    user=
    if [ -x /usr/bin/id ]
    then
       user=`/usr/bin/id -u -n`
    fi
}


# main program
getuser
if [ -n "$user" ]
then
    if [ "$user" != "root" ]
    then
       echo "Only root can run this command"; exit 0
    fi
else
    echo "Can't obtain user name"; exit 0
fi

case $1 in
'start')
	pid=`pidof $LMTPD`
	if [ -n "$pid" ]
	then
	   echo "dbmail lmtpd daemon is already running, PID $pid"
	else
	   $LMTPD &
            pid=`pidof $LMTPD`
	   if [ -n "$pid" ]
	   then
	      echo "dbmail lmtpd daemon started, PID $pid"
	   else
	      echo "Can't start dbmail lmtpd daemon client"
	   fi
	fi
	;;
'stop') 

	pid=`pidof $LMTPD`
	if [ -n "$pid" ]
	then
	   kill $pid
            sleep 4
	   pid=`pidof $LMTPD`
            if [ -n "$pid" ]
            then
               echo "dbmail lmtpd daemon not stopped, sending KILL..."
    	      kill -9 $pid
               sleep 5
	   	pid=`pidof $LMTPD`
            fi
            if [ -n "$pid" ]
            then
               echo "dbmail lmtpd daemon NOT stopped"
  	   else
	      echo "dbmail lmtpd daemon stopped"
	   fi
	else
	   echo "dbmail lmtpd daemon is not running"
	fi
	;;
'restart')
	$0 stop
	$0 start
	;;
'status')
	pid=`pidof $LMTPD`
	if [ -n "$pid" ]
	then
		echo "dbmail lmtpd daemon running, PID $pid"
	else
		echo "dbmail lmtpd daemon stopped"
	fi
	;;
*)
	echo "Use $0 {start|stop|reload|status}";
	;;
esac

 
sysv.txt · Last modified: 2012/02/12 16:38 by are
 
DBMail is developed by Paul J Stevens together with developers world-wide