summaryrefslogtreecommitdiff
path: root/mail/mailscanner/files/mailscanner.in
blob: 5ff9dc4b83e69e17170eb902699661a89979921a (plain) (blame)
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
#! /bin/sh

# PROVIDE: mailscanner
# REQUIRE: mta
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable mailscanner:
# mailscanner_enable (bool):      Set to "NO" by default.
#                                 Set it to "YES" to enable mailscanner
# mailscanner_configfile (path):  Set to "%%PREFIX%%/etc/MailScanner/MailScanner.conf" by default.
# mailscanner_pidfile (path):     Set to "/var/run/MailScanner.pid" by default.
# mailscanner_user (str):         Set to "root" by default. If you changed the "Run As User" variable in MailScanner.conf and wish to disable taint mode, you MUST also set the same value here.
#

. /etc/rc.subr

name="mailscanner"
rcvar=`set_rcvar`

load_rc_config $name

: ${mailscanner_enable="NO"}
: ${mailscanner_configfile="%%PREFIX%%/etc/MailScanner/MailScanner.conf"}
: ${mailscanner_pidfile="/var/run/MailScanner.pid"}

command="%%PREFIX%%/sbin/mailscanner"
pidfile=${mailscanner_pidfile}
command_args="${mailscanner_configfile}"
procname="MailScanner"

required_files="${mailscanner_configfile}"

pid_touch ()
{
	touch $mailscanner_pidfile
	chown $mailscanner_user $mailscanner_pidfile
}

mailscanner_start() {
	su -m ${mailscanner_user} -c "exec ${command} ${command_args}"
}

if [ -n "${mailscanner_user}" ]; then
	start_cmd="mailscanner_start"
	start_precmd="pid_touch"
fi

run_rc_command "$1"