#!/bin/sh ### BEGIN INIT INFO # Provides: clamsmtp # Short-Description: Start virus-scanning SMTP proxy clamsmtp # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO # # clamsmtp init.d script for Debian # # This script is Public Domain. # # See also: clamsmtpd.conf(5), clamsmtpd(8) # ########################################################################### DESC="virus filtering SMTP proxy" NAME=clamsmtpd # Daemon's Name DAEMON=/usr/sbin/${NAME} # Binary CONFFILE=/etc/${NAME}.conf # Configuration File SCRIPTNAME=/etc/init.d/clamsmtp test -f ${DAEMON} || exit 0 # Pull in configuration options set in $CONFFILE. if [ -r ${CONFFILE} ] ; then eval `sed -e ' # Delete comments /^#.*/d # Delete blank lines /^[[:space:]]*$/d # Replace first ": " with "=" and surround with quotes s/^\([a-zA-Z]*\):[[:space:]]*\(.*\)$/\1\="\2";/ ' < ${CONFFILE}` fi # Now, use the variables that we care about PIDFILE=${PidFile:="/var/run/${NAME}/${NAME}.pid"} # PID File RUNDIR=`dirname ${PIDFILE}` CUSER=${User:=clamav} # clamsmtpd user SPOOLDIR=${TempDirectory:="/var/spool/clamsmtp"} # Spool Directory # Init script variables DAEMON_OPTS="" # Override default values test -f /etc/default/clamsmtp && . /etc/default/clamsmtp # Start the daemon d_start() { if [ ! -d $RUNDIR ]; then mkdir -p $RUNDIR chown clamsmtp:clamsmtp $RUNDIR fi start-stop-daemon --start \ --pidfile ${PIDFILE} --quiet --oknodo \ --exec ${DAEMON} -- ${DAEMON_OPTS} } # Stop the daemon d_stop() { start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE} \ --exec ${DAEMON} } ########################################################################### # Main Body case ${1} in start) echo -n "Starting ${DESC}: ${NAME}" d_start echo "." ;; stop) echo -n "Stopping ${DESC}: ${NAME}" d_stop echo "." ;; restart|force-reload) echo -n "Restarting ${DESC}: ${NAME}" d_stop sleep 1 d_start echo "." ;; *) echo "Usage: ${SCRIPTNAME} {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0