aboutsummaryrefslogtreecommitdiff
path: root/system/clamsmtp/rc.clamsmtpd
blob: e71651d10473799147587355cf64e625f2abb962 (plain)
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
#!/bin/sh

# Copyright (c) 2008-2010, Nishant Limbachia, Hoffman Estates, IL, USA
# /etc/rc.d/rc.clamsmtpd

# start/stop/restart clamsmtp mail filter daemon

# To make clamsmtp start automatically at boot, make this
# file executable:  chmod 755 /etc/rc.d/rc.clamsmtpd
# to edit the startup options refer man 8 clamsmtpd


CONFIG="/etc/clamsmtpd.conf"
PIDFILE="/var/run/clamav/clamsmtpd.pid"

clamsmtpd_start() {
	if [ -f $PIDFILE ]; then
		echo "Clamsmtp daemon seems to be running with PID: $(cat $PIDFILE)"
	else
		echo "Starting clamsmtp daemon"
		/usr/sbin/clamsmtpd -f $CONFIG -p $PIDFILE
	fi
}

clamsmtpd_stop() {
	if [ -f $PIDFILE ]; then
		echo "Stopping clamsmtp daemon"
		kill -s 15 $(cat $PIDFILE) 2> /dev/null
	else
		echo "/usr/sbin/clamsmtpd doesn't seem to be running...exiting"
		exit 1
	fi
}

clamsmtpd_restart() {
	clamsmtpd_stop
	sleep 5
	clamsmtpd_start
}

case "$1" in
'start')
	clamsmtpd_start
  ;;
'stop')
	clamsmtpd_stop
  ;;
'restart')
	clamsmtpd_restart
  ;;
*)
	echo "USAGE: $0 start|stop|restart"
	exit 1
  ;;
esac