6b4973bb283ddce03fbdc4dc048296c9e40f2f40
[gentoo.git] / net-firewall / arno-iptables-firewall / arno-iptables-firewall-2.1.0.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5 inherit readme.gentoo-r1 systemd
6
7 DESCRIPTION="Arno's iptables firewall script"
8 HOMEPAGE="https://rocky.eld.leidenuniv.nl"
9
10 MY_PV=$(ver_rs 3 -)
11 MY_PV=${MY_PV/rc/RC}
12 SRC_URI="https://github.com/${PN}/aif/archive/${MY_PV}.tar.gz -> ${P}.tar.gz"
13
14 LICENSE="GPL-2"
15 SLOT="0"
16 KEYWORDS="~amd64 ~x86"
17 IUSE="+plugins rsyslog"
18
19 DEPEND=""
20 RDEPEND="net-firewall/ipset
21         net-firewall/iptables
22         sys-apps/coreutils
23         sys-apps/iproute2
24         plugins? ( net-dns/bind-tools )"
25
26 S="${WORKDIR}/aif-${MY_PV}"
27
28 DISABLE_AUTOFORMATTING="yes"
29 DOC_CONTENTS="You will need to configure /etc/${PN}/firewall.conf
30 before using this package. To start the script, run:
31
32 /etc/init.d/${PN} start (for OpenRC)
33 systemctl start ${PN} (for systemd)
34
35 If you want to start this script at boot, run:
36
37 rc-update add ${PN} default (for OpenRC)
38 systemctl enable ${PN} (for systemd)"
39
40 src_prepare() {
41         sed -i -e 's:/usr/local/share/:/usr/libexec/:' \
42                 etc/"${PN}"/firewall.conf || die "Sed failed!"
43         sed -i -e 's:/usr/local/sbin/:/usr/sbin/:' \
44                 lib/systemd/system/"${PN}.service" || die "Sed failed!"
45         eapply_user
46 }
47
48 src_install() {
49         insinto /etc/"${PN}"
50         doins etc/"${PN}"/firewall.conf
51         doins etc/"${PN}"/custom-rules
52
53         doinitd "${FILESDIR}/${PN}"
54         systemd_dounit lib/systemd/system/"${PN}.service"
55
56         dobin bin/arno-fwfilter
57         dosbin bin/"${PN}"
58
59         insinto /usr/libexec/"${PN}"
60         doins share/"${PN}"/environment
61
62         dodoc CHANGELOG README
63         readme.gentoo_create_doc
64
65         if use plugins
66         then
67                 insinto /etc/"${PN}"/plugins
68                 doins etc/"${PN}"/plugins/*
69
70                 insinto /usr/libexec/"${PN}"/plugins
71                 doins share/"${PN}"/plugins/*.plugin
72
73                 exeinto /usr/libexec/"${PN}"/plugins
74                 doexe share/"${PN}"/plugins/dyndns-host-open-helper
75                 doexe share/"${PN}"/plugins/traffic-accounting-helper
76                 doexe share/"${PN}"/plugins/traffic-accounting-log-rotate
77                 doexe share/"${PN}"/plugins/traffic-accounting-show
78
79                 docinto plugins
80                 dodoc share/"${PN}"/plugins/*.CHANGELOG
81         fi
82
83         if use rsyslog
84         then
85                 insinto /etc/rsyslog.d
86                 newins etc/rsyslog.d/"${PN}".conf 60-"${PN}".conf
87         fi
88
89         doman share/man/man1/arno-fwfilter.1 \
90                 share/man/man8/"${PN}".8
91 }
92
93 pkg_postinst() {
94         ewarn "When you stop this script, all firewall rules are flushed!"
95         ewarn "Make sure to not use multiple firewall scripts simultaneously"
96         ewarn "unless you know what you are doing!"
97         readme.gentoo_print_elog
98 }