summaryrefslogtreecommitdiff
blob: e6d4ad8666665ce56d06431a18182f56c6afcd60 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit depend.php eutils perl-module toolchain-funcs webapp

DESCRIPTION="System monitor for obtaining accurate and up to date info on the performance of a number of systems"
HOMEPAGE="http://www.xs4all.nl/~wpd/symon/"
SRC_URI="http://www.xs4all.nl/~wpd/symon/philes/${P}.tar.gz
	syweb? ( http://www.xs4all.nl/~wpd/symon/philes/syweb-0.57.tar.gz )"

LICENSE="BSD-2"
SLOT="0"
KEYWORDS="~amd64 ~sparc ~x86"
IUSE="client symux syweb"

CDEPEND="client? ( dev-lang/perl )
	symux? ( net-analyzer/rrdtool )"
DEPEND="${CDEPEND}
	sys-devel/pmake"
RDEPEND="${CDEPEND}
	syweb? ( virtual/httpd-php )"

S=${WORKDIR}/${PN}
WEBAPP_MANUAL_SLOT="yes"

pkg_setup() {
	if use syweb ; then
		require_php_with_any_use gd gd-external
		webapp_pkg_setup
	fi
}

src_unpack() {
	unpack ${A}

	epatch "${FILESDIR}"/${PN}-symon.conf.patch
	use symux && epatch "${FILESDIR}"/${PN}-symux.conf.patch

	if use syweb ; then
		epatch "${FILESDIR}"/${PN}-syweb-class_lexer.inc.patch
		epatch "${FILESDIR}"/${PN}-syweb-setup.inc.patch
		epatch "${FILESDIR}"/${PN}-syweb-total_firewall.layout.patch
	fi

	if ! use client ; then
		sed -i -e "/SUBDIR/ s/client//" "${S}"/Makefile || die "sed failed."
	fi
	if ! use symux ; then
		sed -i -e "/SUBDIR/ s/symux//" "${S}"/Makefile || die "sed failed."
	fi
}

src_compile() {
	MAKE=pmake emake CC="$(tc-getCC)" CFLAGS+="${CFLAGS}" \
		STRIP=true || die "emake failed."
}

src_install() {
	insinto /etc
	doins symon/symon.conf

	newinitd "${FILESDIR}"/${PN}-init.d ${PN} || die "newinitd failed."

	dodoc CHANGELOG HACKERS TODO

	doman symon/symon.8
	dosbin symon/symon

	dodir /usr/share/symon
	insinto /usr/share/symon
	doins symon/c_config.sh
	fperms a+x,u-w /usr/share/symon/c_config.sh

	if use client ; then
		dobin client/getsymonitem.pl

		perlinfo
		insinto ${SITE_LIB}
		doins client/SymuxClient.pm
	fi

	if use symux ; then
		insinto /etc
		doins symux/symux.conf

		newinitd "${FILESDIR}"/symux-init.d symux || die "newinitd failed."

		doman symux/symux.8
		dosbin symux/symux

		insinto /usr/share/symon
		doins symux/c_smrrds.sh
		fperms u-w,u+x /usr/share/symon/c_smrrds.sh

		dodir /var/lib/symon/rrds/localhost
	fi

	if use syweb ; then
		docinto /layouts
		dodoc "${WORKDIR}"/syweb/symon/total_firewall.layout

		webapp_src_preinst

		dodir "${MY_HTDOCSDIR}"/cache
		dodir "${MY_HTDOCSDIR}"/layouts
		webapp_serverowned "${MY_HTDOCSDIR}"/cache
		insinto "${MY_HTDOCSDIR}"
		doins -r "${WORKDIR}"/syweb/htdocs/syweb/*
		webapp_configfile "${MY_HTDOCSDIR}"/setup.inc

		webapp_src_install
	fi
}

pkg_postinst() {
	use client && perl-module_pkg_postinst

	if use syweb ; then
		elog "Test your syweb configuration by pointing your browser at:"
		elog "http://${VHOST_HOSTNAME}/${PN}/configtest.php"
		webapp_pkg_postinst
	fi

	elog "You'll need to setup your /etc/symon.conf and "
	elog "/etc/symux.conf before running these daemons for "
	elog "the first time."
	elog "To test the configuration run sym{on,ux} -t"
	elog "To create the RRDs run /usr/share/symon/c_smrrds.sh all"
	elog "NOTE that symon won't chroot by default."
}

pkg_prerm() {
	use syweb && webapp_pkg_prerm
}