summaryrefslogtreecommitdiff
path: root/security/clamav/files/clamav-clamd.in
blob: b9c562f47987ccbbd5948867a5cd0be3e717a2a6 (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
51
#!/bin/sh

# PROVIDE: clamav_clamd
# REQUIRE: LOGIN
# BEFORE: mail
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable clamd:
#
# clamav_clamd_enable="YES"
# clamav_clamd_flags="<set as needed>"
#
# See clamd(8) for flags
#

. /etc/rc.subr

name=clamav_clamd
rcvar=clamav_clamd_enable

# read settings, set default values
load_rc_config "$name"

: ${clamav_clamd_enable:=NO}
: ${clamav_clamd_socket="%%CLAMAV_CLAMD_SOCKET%%"}
: ${clamav_clamd_pidfile="%%CLAMAV_CLAMD_PIDFILE%%"}
: ${clamav_clamd_user="%%CLAMAVUSER%%"}

command=%%PREFIX%%/sbin/clamd
required_dirs=%%DBDIR%%
required_files=%%PREFIX%%/etc/clamd.conf

start_precmd=clamav_clamd_precmd
extra_commands=reload
reload_cmd="%%PREFIX%%/bin/clamdscan --reload"

#clamav .93 won't start without a valid main.c[vl]d file
clamav_clamd_precmd()
{
	local rundir=${clamav_clamd_pidfile%/*}
	if [ ! -d $rundir ] ; then
		install -d -m 0755 -o ${clamav_clamd_user} -g ${clamav_clamd_user} $rundir
	fi
	if [ ! -f %%DBDIR%%/main.cvd -a ! -f %%DBDIR%%/main.cld ];then
		echo "Missing %%DBDIR%%/*.cvd or *.cld files.  You must run freshclam first"
		exit 1
	fi
}

run_rc_command "$1"