summaryrefslogtreecommitdiff
blob: eb285981b2f9c9acc6f15fad364d27e2853ebf16 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-proxy/dansguardian/dansguardian-2.12.0.3-r2.ebuild,v 1.5 2015/03/02 09:30:41 ago Exp $

EAPI="5"

inherit eutils user

DESCRIPTION="Web content filtering via proxy"
HOMEPAGE="http://www.${PN}.org"
SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="amd64 ppc ~ppc64 ~sparc x86"
IUSE="avast backtrace clamav commandline debug email +fancydm icap kaspersky +lfs logrotate ntlm orig-ip +pcre static-libs trickledm"

RDEPEND="sys-libs/zlib
	clamav? ( app-antivirus/clamav )
	logrotate? ( app-admin/logrotate )
	ntlm? ( virtual/libiconv )
	pcre? ( >=dev-libs/libpcre-8.32 )"
DEPEND="${RDEPEND}
	virtual/pkgconfig"

WIKI="http://contentfilter.futuragts.com/wiki/doku.php"

pkg_setup() {
	enewgroup ${PN}
	enewuser ${PN} -1 -1 /dev/null ${PN}
}

src_configure() {
	local debug
	if use debug ; then
		debug="$(use_with debug dgdebug)"
	fi

	econf \
		$(use_enable avast avastd) \
		$(use_enable backtrace segv-backtrace) \
		$(use_enable clamav clamd) \
		$(use_enable commandline) \
		${debug} \
		$(use_enable email) \
		$(use_enable fancydm) \
		$(use_enable icap) \
		$(use_enable kaspersky kavd) \
		$(use_enable lfs) \
		--with-logdir=/var/log/${PN} \
		$(use_enable ntlm) \
		$(use_enable orig-ip) \
		$(use_enable pcre) \
		--with-piddir=/var/run \
		--with-proxygroup=${PN} \
		--with-proxyuser=${PN} \
		$(use_enable static-libs static-zlib) \
		$(use_enable trickledm)
}

src_install() {
	default

	# Edit config files for virus scanners chosen based on USE flags.
	if use avast; then
		sed -r -i -e 's/^#( *contentscanner *=.*avastdscan[.]conf.*)/\1/' "${D}/etc/${PN}/${PN}.conf"
	fi

	if use clamav; then
		sed -r -i -e 's/[ \t]+use dns/& clamd/' "${D}/etc/init.d/${PN}"
		sed -r -i -e 's/^#( *contentscanner *=.*clamdscan[.]conf.*)/\1/' "${D}/etc/${PN}/${PN}.conf"
	fi

	if use commandline; then
		sed -r -i -e 's/^#( *contentscanner *=.*commandlinescan[.]conf.*)/\1/' "${D}/etc/${PN}/${PN}.conf"
	fi

	if use icap; then
		sed -r -i -e 's/^#( *contentscanner *=.*icapscan[.]conf.*)/\1/' "${D}/etc/${PN}/${PN}.conf"
	fi

	if use kaspersky; then
		sed -r -i -e 's/^#( *contentscanner *=.*kavdscan[.]conf.*)/\1/' "${D}/etc/${PN}/${PN}.conf"
	fi

	# Install Gentoo init script
	newinitd "${FILESDIR}/${PN}.init" ${PN}

	# Install log rotation file.
	if use logrotate; then
		insinto /etc/logrotate.d
		newins "${FILESDIR}/${PN}.logrotate" ${PN}
	else
		exeinto /etc/cron.weekly
		newexe data/scripts/logrotation ${PN}.cron
	fi

	keepdir /var/log/${PN}
	fperms o-rwx /var/log/${PN}
}

pkg_postinst() {
	local runas="${PN}:${PN}"

	if [ -d "${ROOT}/var/log/${PN}" ] ; then
		chown -R ${runas} "${ROOT}/var/log/${PN}"
		chmod o-rwx "${ROOT}/var/log/${PN}"
	fi

	einfo "For assistance configuring ${PN}, visit the wiki at ${WIKI}"
}