File: clamsmtp.init

package info (click to toggle)
clamsmtp 1.10-7
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 1,352 kB
  • ctags: 333
  • sloc: sh: 3,919; ansic: 3,286; makefile: 20
file content (98 lines) | stat: -rw-r--r-- 2,392 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/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