summaryrefslogtreecommitdiff
path: root/gentoo-linux/net-misc/anytun/anytun-0.3.1.ebuild
blob: b1a083b3fe22f833ffcd1f7c3a2af25bab33d9da (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
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
# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit eutils

DESCRIPTION="VPN daemon using Secure Anycast Tunneling"
HOMEPAGE="http://anytun.org/"
SRC_URI="http://anytun.org/~equinox/${P}.tar.gz"
LICENSE="GPL-3"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="doc examples gcrypt"
DEPEND=">=dev-libs/boost-1.35
	<dev-libs/boost-1.40
	gcrypt? ( dev-libs/libgcrypt )
	!gcrypt? ( dev-libs/openssl )
	doc? ( <app-text/asciidoc-8.5.0 )" # asciidoc a2x <= 8.5.0 requires the -L switch
RDEPEND="${DEPEND}"
S="${WORKDIR}/${P}/src"

src_compile() {
	local myconf=""
	use gcrypt || myconf="${myconf} --use-ssl-crypto"
	# anytun's configure right now only takes 1! option (no --prefix etc), so econf would be too
	# much for your little script and the build would fail
	#econf ${myconf} || die "configure failed"
	./configure ${myconf} || die "configure failed"
	emake || die "make failed"
	if use doc ; then
		einfo "Building manpages"
		emake manpage || die "failed building manpages"
	fi
}

src_install() {
	local pkgroot="${WORKDIR}/${P}"
	dosbin anytun || die "failed to copy/install an executable"
	dobin anytun-config anytun-controld anytun-showtables anytun-nosync || die "failed to copy/install an executable"
	newinitd "${FILESDIR}/${PN}-0.3.1.init" anytun || die "failed to copy/install initrd script"
	insinto /usr/share/${P}/wireshark-lua/
	doins ${pkgroot}/wireshark-lua/* || die "failed to install wireshark-lua contrib script"
	dodir /var/run/anytun || die "failed to mkdir"
	keepdir /var/run/anytun
	dodir /var/run/anytun-controld || die "failed to mkdir"
	keepdir /var/run/anytun-controld
	if use examples; then
		insinto /usr/share/doc/${PF}/etc-anytun-examples/
		doins -r ${pkgroot}/etc/anytun/* || die "failed to install examples"
	fi
	if use doc; then
		dodoc ${pkgroot}/AUTHORS ${pkgroot}/ChangeLog ${pkgroot}/LICENSE ${pkgroot}/README || die "failed to install docs"
		cd ${S}/man/
		doman anyrtpproxy.8 anytun-config.8 anytun-controld.8 anytun-showtables.8 anytun.8 || die "failed to install manpages"
		prepallman || die "failed to prep manpages"
	fi
}

pkg_config() {
	if [ ! -d /usr/share/doc/${PF}/etc-anytun-examples/ ]; then
		die "can't copy example configs since examples were not installed"
	fi
	mkdir -p ${ROOT}/etc/anytun/ || die "couldn't mkdir ${ROOT}/etc/anytun/"
	cp -r ${ROOT}usr/share/doc/${PF}/etc-anytun-examples/* ${ROOT}/etc/anytun/ || die "failed to copy examples"
}

pkg_postinst() {
	enewgroup anytun
	enewuser anytun -1 -1 /var/run/anytun anytun
	if use examples; then	
		einfo "Example configuration files have been installed in"
		einfo " /usr/share/doc/${PF}/etc-anytun-examples/"
		einfo "You can copy them to /etc/anytun using"
		einfo "> emerge --config anytun"
		einfo
	else
		einfo "You did not install examples."
		einfo "If you need example configs to get you started, "
		einfo "you can extract them from the anytun.tar.gz or  "
		einfo "e.g.: tar xzv --strip-components 3 -f ${DISTDIR}/${P}.tar.gz -C /etc/anytun/ ${P}/etc/anytun"
		einfo "or visit the anytun wiki online"
		einfo
	fi
	einfo "Note that each VPN gets it's own directory under /etc/anytun/"
	einfo "You can either add tunnels to /etc/anytun/autostart and"
	einfo "start them using /etc/init.d/anytun"
	einfo "Or you can forget the autostart file and create"
	einfo "gentoo-style anytun.{VPN} initrd scripts for each VPN"
	einfo "e.g.> ln -s /etc/init.d/anytun /etc/init.d/anytun.client1"
	einfo
	einfo "Don't forget to "
	einfo "> rc-update add anytun default"
	einfo "or"
	einfo "> rc-update add anytun.client1 default"
	einfo
	einfo "You can disect anytun traffic using wireshark by plugging the script"
	einfo "/usr/share/${P}/wireshark-lua/satp.lua into wireshark"
}