File opensmtpd.init of Package opensmtpd
#!/bin/bash
#
# chkconfig: 345 31 69
# description: Simple Mail Transfer Protocol daemon
#
### BEGIN INIT INFO
# Provides: smtpd opensmtpd
# Required-Start: $syslog $network $remote_fs
# Required-Stop: $syslog $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 4 6
# Short-Description: Simple Mail Transfer Protocol daemon
# Description: smtpd is a Simple Mail Transfer Protocol (SMTP) daemon which can be
# used as a machine's primary mail system. smtpd can listen on a network
# interface and handle SMTP transactions; it can also be fed messages
# through the standard sendmail(8) interface. It can relay messages
# through remote mail transfer agents or store them locally using either
# the mbox or maildir format. This implementation supports SMTP as
# defined by RFC 5321 as well as several extensions. A running smtpd can
# be controlled through smtpctl.
### END INIT INFO
OPENSMTPD_BIN=/usr/sbin/smtpd
OPENSMTPD_PID=/var/run/smtpd.pid
OPENSMTPCTL=/usr/sbin/smtpctl
if [ -r /etc/rc.status ]
then
source /etc/rc.status
START="/sbin/startproc"
STATUS="/sbin/checkproc"
SUCCESS="echo \$rc_done"
FAILURE="echo \$rc_failed"
else
source /etc/rc.d/init.d/functions
START="daemon"
STATUS="status"
SUCCESS="success; echo"
FAILURE="failure; echo"
fi
[ -r /etc/sysconfig/opensmtpd ] && source /etc/sysconfig/opensmtpd
RETVAL=0
case "$1" in
start)
echo -n "Starting smtpd: "
${START} ${OPENSMTPD_BIN} -f ${CONF_FILE:-/etc/opensmtpd/smtpd.conf}
RETVAL=$?
;;
stop)
echo -n "Stopping smtpd: "
${OPENSMTPCTL} stop 2> /dev/null
RETVAL=$?
;;
restart)
if $0 checkconf
then
$0 stop
$0 start
unset RETVAL
else
exit 1
fi
;;
status)
echo -n "Status of smtpd: "
${STATUS} ${OPENSMTPD_BIN} > /dev/null 2>&1
RETVAL=$?
;;
checkconf)
echo -n "Checking configuration of smtpd: "
${OPENSMTPD_BIN} -n 2> /dev/null
RETVAL=$?
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|checkconf}"
exit 1
;;
esac
[ -z ${RETVAL} ] && exit
[ ${RETVAL} -eq 0 ] && eval "${SUCCESS}" || eval "${FAILURE}"
exit ${RETVAL}