summaryrefslogtreecommitdiff
path: root/net-firewall/fwknop/fwknop-1.9.12.ebuild
blob: 86047b7002c460b8562ca5c7f814f8cb11bc6112 (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=2

inherit perl-app

DESCRIPTION="Single Packet Authorization and Port Knocking"
SRC_URI="http://www.cipherdyne.org/fwknop/download/${PN}-nodeps-${PV}.tar.gz"
HOMEPAGE="http://www.cipherdyne.org/fwknop"

SLOT="0"
LICENSE="GPL-2"
KEYWORDS="~x86"
IUSE="gpg +server"

RDEPEND="
	dev-perl/Class-MethodMaker
	dev-perl/crypt-cbc
	dev-perl/Crypt-Rijndael
	dev-perl/TermReadKey
	dev-perl/Net-RawIP
	dev-perl/Net-IPv4Addr
	virtual/perl-Digest-SHA
	virtual/perl-net-ping
	server? (
		dev-perl/IPTables-Parse
		dev-perl/IPTables-ChainMgr
		dev-perl/Net-Pcap
		dev-perl/Unix-Syslog
		net-firewall/iptables
		net-misc/whois
		virtual/logger
		virtual/mailx
		)
	gpg? ( dev-perl/GnuPG-Interface )"

src_install() {
	# install client binary
	dobin fwknop

	if use server; then
		# install daemons
		insinto /usr
		dosbin fwknop_serv fwknopd knopmd knoptm knopwatchd

		# fix config
		fix_conf

		# install configs
		insinto /etc/fwknop
		doins *.conf
		fperms 600 /etc/fwknop/access.conf

		# init.d
		newinitd init-scripts/fwknop-init.gentoo fwknop

		# create (and keep) dirs for the daemons
		keepdir /var/log/fwknop /var/run/fwknop

		# install manpages
		doman *.8
	else
		# only install the client manpage
		doman fwknop.8
	fi

	dodoc CREDITS Change* README README.* VERSION
}

pkg_postinst() {
	if use server; then
		echo
		elog "Please be sure to edit /etc/fwknop/fwknop.conf to reflect your system's"
		elog "configuration or it may not work correctly or start up. Specifically, check"
		elog "the validity of the HOSTNAME setting and EMAIL_ADDRESSES"
		echo
		elog "You must edit /etc/fwknop/access.conf for fwknop to work correctly."
	fi
}

fix_conf() {
	cp fwknop.conf fwknop.conf.orig

	# Ditch the _CHANGEME_ for hostname, substituting in our real hostname
	sed -i "s:HOSTNAME\(.\+\)\_CHANGEME\_;:HOSTNAME\1$(hostname --fqdn);:" fwknop.conf || die "fix_conf failed"

	# Fix up paths
	sed -i "s:/sbin/syslogd:/usr/sbin/syslogd:g" fwknop.conf || die "fix_conf failed"
	sed -i "s:/sbin/syslog-ng:/usr/sbin/syslog-ng:g" fwknop.conf || die "fix_conf failed"
	sed -i "s:/usr/bin/whois_psad:/usr/bin/whois:g" fwknop.conf || die "fix_conf failed"
}