summaryrefslogtreecommitdiff
blob: 42ce8a971b5c3868e291a392592b74afaf41a799 (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
112
113
114
115
116
117
118
119
120
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-analyzer/munin/munin-1.3.2-r3.ebuild,v 1.1 2006/11/13 10:52:33 robbat2 Exp $

inherit eutils

DESCRIPTION="Munin Server Monitoring Tool"
HOMEPAGE="http://munin.sourceforge.net"
SRC_URI="mirror://sourceforge/munin/${PN}_${PV}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~ppc ~amd64"
IUSE="doc minimal munin-irc munin-dhcp munin-surfboard munin-apache munin-squid ssl"

# Upstream's listing of required modules is NOT correct!
DEPEND_COM="dev-lang/perl
			dev-perl/net-server
			sys-process/procps
			ssl? ( dev-perl/Net-SSLeay )
			dev-perl/Net-SNMP
			dev-perl/DateManip
			virtual/perl-Time-HiRes
			virtual/perl-Digest-MD5
			virtual/perl-Getopt-Long
			virtual/perl-Storable
			virtual/perl-Text-Balanced
			!minimal? ( dev-perl/HTML-Template
						net-analyzer/rrdtool )
			munin-irc? ( dev-perl/Net-IRC )
			munin-dhcp? ( dev-perl/Net-Netmask dev-perl/libwww-perl )
			munin-surfboard? ( dev-perl/libwww-perl )
			munin-apache? ( dev-perl/libwww-perl )
			munin-squid? ( virtual/perl-MIME-Base64 )"
			# Sybase isn't supported in Gentoo
			#munin-sybase? (	 dev-perl/DBD-Sybase )

DEPEND="${DEPEND_COM}
		doc? ( app-text/htmldoc
			   app-text/html2text )"
RDEPEND="${DEPEND_COM}
		virtual/cron"

pkg_setup() {
	enewgroup munin
	enewuser munin 177 -1 /var/lib/munin munin
}

src_unpack() {
	if use !minimal; then
		if ! built_with_use net-analyzer/rrdtool perl ; then
			die 'Sorry, munin needs net-analyzer/rrdtool built with USE=perl.'
		fi
	fi
	unpack ${A}
	# upstream needs a lot of DESTDIR loving
	# and Gentoo location support
	EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${PN}-1.3.2-r3-Makefile.patch
	# Fix noise in the plugins
	EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${PN}-1.3.2-plugin-cleanup.patch
	# Make it work with new versions of Rrdtool where : in COMMENT blocks must
	# be escaped!
	EPATCH_OPTS="-p1 -d ${S}" epatch ${FILESDIR}/${PN}-1.3.2-rrdtool-comments.patch
}

src_compile() {
	emake build build-man || die "build/build-man failed"
	if use doc; then
		emake build-doc || die "build-doc failed"
	fi
}

src_install() {
	local dirs
	dirs="/var/log/munin /var/lib/munin"
	dirs="${dirs} /var/lib/munin/plugin-state"
	dirs="${dirs} /var/run/munin/plugin-state"
	keepdir ${dirs}

	emake DESTDIR="${D}" install-main install-man install-node install-node-plugins || die "install failed"
	fowners munin:munin ${dirs}

	if use doc; then
		emake DESTDIR="${D}" install-doc install-man || die "install docs failed"
	fi

	insinto /etc/munin/plugin-conf.d/
	newins ${FILESDIR}/${P}-plugins.conf munin-node

	# ensure TLS is disabled is built without SSL
	use ssl || echo "tls disabled" >>${D}/etc/munin/munin-node.conf

	# make sure we've got everything in the correct directory
	insinto /var/lib/munin
	newins ${FILESDIR}/${P}-crontab crontab
	newinitd ${FILESDIR}/munin-init.d munin-node
	dodoc ChangeLog INSTALL README-apache-cgi.in README.api logo.eps
	munin-doc-base.html munin-faq-base.html TODO.plugins
	newdoc server/TODO TODO.server
	newdoc node/TODO TODO.node
}

pkg_config() {
	crontab -l -u munin 2>/dev/null | grep --silent '.*'
	if [ $? -eq 0 ]; then
		die "Crontab already install for user munin. Not overwriting."
	fi
	einfo "Press enter to install the default crontab for the munin master"
	einfo "installation from /var/lib/munin/crontab"
	einfo "If you have a large site, you may wish to customize it."
	read
	crontab -u munin /var/lib/munin/crontab
}

pkg_postinst() {
	einfo "Please follow the munin documentation to set up the plugins you"
	einfo "need, afterwards start munin-node via /etc/init.d/munin-node."
	einfo "To have munin's cronjob automatically configured for you if this is"
	einfo "your munin master installation, please:"
	einfo "emerge --config net-analyzer/munin"
}