aboutsummaryrefslogtreecommitdiffstats
path: root/main/clamav/freshclam.initd
blob: 7961c7f8070c7e7934ad7857c3c3d1ad7557501a (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
52
53
54
55
56
57
58
#!/sbin/runscript

opts="logfix reload"

NAME=freshclam
DAEMON=/usr/bin/$NAME
CONF=/etc/clamav/freshclam.conf

depend() {
	need net
}

start() {
	ebegin "Starting freshclam"
	start-stop-daemon --start --quiet \
		--nicelevel ${FRESHCLAM_NICELEVEL:-0} \
		--exec /usr/bin/freshclam -- -d
	retcode=$?
	if [ ${retcode} = 1 ]; then
		eend 0
		einfo "Virus databases are already up to date."
	else
		eend ${retcode} "Failed to start freshclam"
	fi
}

stop() {
	ebegin "Stopping ${NAME}"
	start-stop-daemon --stop --quiet --name ${NAME}
	eend $?
}

reload() {
	ebegin "Reloading ${NAME}"
	if ! service_started "${NAME}" ; then
		eend 1 "${NAME} is not started"
		return 1
	fi
	start-stop-daemon --stop --oknodo --signal HUP \
		--exec ${DAEMON} --name $NAME
	eend $?
}


logfix() {
	# fix freshclam log permissions
	# (might be clobbered by logrotate or something)
	logfile=$(awk '$1 == "UpdateLogFile" { print $2 }' $CONF)
	local freshclam_user=$(awk '$1 == "DatabaseOwner" { print $2 }' $CONF)
	if [ -n "${logfile}" -a -n "${clamav_user}" ]; then
		if [ ! -f "${logfile}" ]; then
			touch ${logfile}
		fi	
		chown ${freshclam_user} ${logfile}
		chmod 640 ${logfile}
	fi
}