Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 581928 | Differences between
and this patch

Collapse All | Expand All

(-)a/app-antivirus/clamav/files/clamd.initd-r3 (-121 lines)
Lines 1-121 Link Here
1
#!/sbin/runscript
2
# Copyright 1999-2013 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
# $Id$
5
6
daemon_clamd="/usr/sbin/clamd"
7
daemon_freshclam="/usr/bin/freshclam"
8
daemon_milter="/usr/sbin/clamav-milter"
9
10
extra_commands="logfix"
11
12
depend() {
13
	use net
14
	provide antivirus
15
}
16
17
get_config() {
18
	clamconf | sed 's/["=]//g' | \
19
	awk "{
20
	if(\$0==\"Config file: $1.conf\") S=1
21
	if(S==1&&\$0==\"\") {
22
		print \"$3\"
23
		exit
24
	}
25
	if(S==1&&\$1~\"^$2\$\") {
26
		print \$2!=\"disabled\"?\$2:\"$3\"
27
		exit
28
	}
29
	}"
30
}
31
32
start() {
33
	local clamd_socket=$(get_config clamd LocalSocket /var/run/clamav/clamd.sock)
34
	local clamd_user=$(get_config clamd User clamav)
35
	local freshclam_user=$(get_config freshclam DatabaseOwner clamav)
36
	logfix
37
38
	if [ "${START_CLAMD}" = "yes" ]; then
39
		checkpath --quiet --mode 755 \
40
			--owner "${clamd_user}":"${clamd_user}" \
41
			--directory `dirname ${clamd_socket}`
42
		if [ -S "${clamd_socket}" ]; then
43
			rm -f ${clamd_socket}
44
		fi
45
		ebegin "Starting clamd"
46
		start-stop-daemon --start --quiet \
47
			--nicelevel ${CLAMD_NICELEVEL:-0} \
48
			--exec ${daemon_clamd}
49
		eend $? "Failed to start clamd"
50
	fi
51
52
	if [ "${START_FRESHCLAM}" = "yes" ]; then
53
		ebegin "Starting freshclam"
54
		start-stop-daemon --start --quiet \
55
			--nicelevel ${FRESHCLAM_NICELEVEL:-0} \
56
			--exec ${daemon_freshclam} -- -d
57
		retcode=$?
58
		if [ ${retcode} = 1 ]; then
59
			eend 0
60
			einfo "Virus databases are already up to date."
61
		else
62
			eend ${retcode} "Failed to start freshclam"
63
		fi
64
	fi
65
66
	if [ "${START_MILTER}" = "yes" ]; then
67
		if [ -z "${MILTER_CONF_FILE}" ]; then
68
			MILTER_CONF_FILE="/etc/clamav-milter.conf"
69
		fi
70
71
		ebegin "Starting clamav-milter"
72
		start-stop-daemon --start --quiet \
73
			--nicelevel ${MILTER_NICELEVEL:-0} \
74
			--exec ${daemon_milter} -- -c ${MILTER_CONF_FILE}
75
		eend $? "Failed to start clamav-milter"
76
	fi
77
}
78
79
stop() {
80
	if [ "${START_CLAMD}" = "yes" ]; then
81
		ebegin "Stopping clamd"
82
		start-stop-daemon --stop --quiet --name clamd
83
		eend $? "Failed to stop clamd"
84
	fi
85
	if [ "${START_FRESHCLAM}" = "yes" ]; then
86
		ebegin "Stopping freshclam"
87
		start-stop-daemon --stop --quiet --name freshclam
88
		eend $? "Failed to stop freshclam"
89
	fi
90
	if [ "${START_MILTER}" = "yes" ]; then
91
		ebegin "Stopping clamav-milter"
92
		start-stop-daemon --stop --quiet --name clamav-milter
93
		eend $? "Failed to stop clamav-milter"
94
	fi
95
}
96
97
logfix() {
98
	if [ "${START_CLAMD}" = "yes" ]; then
99
		# fix clamd log permissions
100
		# (might be clobbered by logrotate or something)
101
		local logfile=$(get_config clamd LogFile)
102
		if [ -n "${logfile}" ]; then
103
			checkpath --quiet \
104
				--owner "${clamd_user}":"${clamd_user}" \
105
				--mode 640 \
106
				--file ${logfile}
107
		fi
108
	fi
109
110
	if [ "${START_FRESHCLAM}" = "yes" ]; then
111
		# fix freshclam log permissions
112
		# (might be clobbered by logrotate or something)
113
		local logfile=$(get_config freshclam UpdateLogFile)
114
		if [ -n "${logfile}" ]; then
115
			checkpath --quiet \
116
				--owner "${freshclam_user}":"${freshclam_user}" \
117
				--mode 640 \
118
				--file ${logfile}
119
		fi
120
	fi
121
}
(-)a/app-antivirus/clamav/files/clamd.initd-r5 (-127 lines)
Lines 1-126 Link Here
1
#!/sbin/runscript
2
# Copyright 1999-2013 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
4
# $Id$
5
6
daemon_clamd="/usr/sbin/clamd"
7
daemon_freshclam="/usr/bin/freshclam"
8
daemon_milter="/usr/sbin/clamav-milter"
9
10
extra_commands="logfix"
11
12
depend() {
13
	use net
14
	provide antivirus
15
}
16
17
get_config() {
18
	clamconf | sed 's/["=]//g' | \
19
	awk "{
20
	if(\$0==\"Config file: $1.conf\") S=1
21
	if(S==1&&\$0==\"\") {
22
		print \"$3\"
23
		exit
24
	}
25
	if(S==1&&\$1~\"^$2\$\") {
26
		print \$2!=\"disabled\"?\$2:\"$3\"
27
		exit
28
	}
29
	}"
30
}
31
32
start() {
33
	# populate variables and fix log file permissions
34
	logfix
35
36
	if [ "${START_CLAMD}" = "yes" ]; then
37
		checkpath --quiet --mode 755 \
38
			--owner "${clamd_user}":"${clamd_user}" \
39
			--directory `dirname ${clamd_socket}`
40
		if [ -S "${clamd_socket}" ]; then
41
			rm -f ${clamd_socket}
42
		fi
43
		ebegin "Starting clamd"
44
		start-stop-daemon --start --quiet \
45
			--nicelevel ${CLAMD_NICELEVEL:-0} \
46
			--exec ${daemon_clamd}
47
		eend $? "Failed to start clamd"
48
	fi
49
50
	if [ "${START_FRESHCLAM}" = "yes" ]; then
51
		checkpath --quiet --mode 755 \
52
			--owner "${clamd_user}":"${clamd_user}" \
53
			--directory `dirname ${clamd_socket}`
54
		ebegin "Starting freshclam"
55
		start-stop-daemon --start --quiet \
56
			--nicelevel ${FRESHCLAM_NICELEVEL:-0} \
57
			--exec ${daemon_freshclam} -- -d
58
		retcode=$?
59
		if [ ${retcode} = 1 ]; then
60
			eend 0
61
			einfo "Virus databases are already up to date."
62
		else
63
			eend ${retcode} "Failed to start freshclam"
64
		fi
65
	fi
66
67
	if [ "${START_MILTER}" = "yes" ]; then
68
		if [ -z "${MILTER_CONF_FILE}" ]; then
69
			MILTER_CONF_FILE="/etc/clamav-milter.conf"
70
		fi
71
72
		ebegin "Starting clamav-milter"
73
		start-stop-daemon --start --quiet \
74
			--nicelevel ${MILTER_NICELEVEL:-0} \
75
			--exec ${daemon_milter} -- -c ${MILTER_CONF_FILE}
76
		eend $? "Failed to start clamav-milter"
77
	fi
78
}
79
80
stop() {
81
	if [ "${START_CLAMD}" = "yes" ]; then
82
		ebegin "Stopping clamd"
83
		start-stop-daemon --stop --quiet --name clamd
84
		eend $? "Failed to stop clamd"
85
	fi
86
	if [ "${START_FRESHCLAM}" = "yes" ]; then
87
		ebegin "Stopping freshclam"
88
		start-stop-daemon --stop --quiet --name freshclam
89
		eend $? "Failed to stop freshclam"
90
	fi
91
	if [ "${START_MILTER}" = "yes" ]; then
92
		ebegin "Stopping clamav-milter"
93
		start-stop-daemon --stop --quiet --name clamav-milter
94
		eend $? "Failed to stop clamav-milter"
95
	fi
96
}
97
98
logfix() {
99
	clamd_socket=$(get_config clamd LocalSocket /run/clamav/clamd.sock)
100
	clamd_user=$(get_config clamd User clamav)
101
	freshclam_user=$(get_config freshclam DatabaseOwner clamav)
102
103
	if [ "${START_CLAMD}" = "yes" ]; then
104
		# fix clamd log permissions
105
		# (might be clobbered by logrotate or something)
106
		local logfile=$(get_config clamd LogFile)
107
		if [ -n "${logfile}" ]; then
108
			checkpath --quiet \
109
				--owner "${clamd_user}":"${clamd_user}" \
110
				--mode 640 \
111
				--file ${logfile}
112
		fi
113
	fi
114
115
	if [ "${START_FRESHCLAM}" = "yes" ]; then
116
		# fix freshclam log permissions
117
		# (might be clobbered by logrotate or something)
118
		local logfile=$(get_config freshclam UpdateLogFile)
119
		if [ -n "${logfile}" ]; then
120
			checkpath --quiet \
121
				--owner "${freshclam_user}":"${freshclam_user}" \
122
				--mode 640 \
123
				--file ${logfile}
124
		fi
125
	fi
126
}
127
- 

Return to bug 581928