summaryrefslogtreecommitdiff
blob: 65c3fb9df5538df8ce56dd64eeb39f5f46850f8f (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

WEBAPP_OPTIONAL="yes"

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

DESCRIPTION="Performance and information monitoring tool"
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.58.tar.gz )"

LICENSE="BSD-2"
WEBAPP_MANUAL_SLOT="yes"
SLOT="0"
KEYWORDS="~amd64 ~sparc ~x86"
IUSE="perl symux syweb vhosts"

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

S=${WORKDIR}/${PN}

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 perl ; then
		sed -i "/SUBDIR/s/client//" "${S}"/Makefile || die "sed client failed"
	fi
	if ! use symux ; then
		sed -i "/SUBDIR/s/symux//" "${S}"/Makefile || die "sed symux failed"
	fi
}

src_compile() {
	MAKE=pmake MAKEOPTS= emake \
		AR="$(tc-getAR)" \
		CC="$(tc-getCC)" \
		CFLAGS+="${CFLAGS}" \
		RANLIB="$(tc-getRANLIB)" \
		STRIP=true || die "emake failed"
}

src_install() {
	insinto /etc
	doins symon/symon.conf || die "doins symon.conf failed"

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

	dodoc CHANGELOG HACKERS TODO || die "dodoc failed"

	doman symon/symon.8 || die "doman symon failed"
	dosbin symon/symon || die "dosbin symon failed"

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

	if use perl ; then
		dobin client/getsymonitem.pl || die "dobin getsymonitem.pl failed"

		perlinfo
		insinto ${SITE_LIB}
		doins client/SymuxClient.pm || die "doins SymuxClient.pm failed"
	fi

	if use symux ; then
		insinto /etc
		doins symux/symux.conf || die "doins symux.conf failed"

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

		doman symux/symux.8 || die "doman symux failed"
		dosbin symux/symux || die "dosbin symux failed"

		insinto /usr/share/symon
		doins symux/c_smrrds.sh || die "doins c_smrrds.sh failed"
		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* || die "dodoc layouts failed"
		docinto syweb
		dodoc "${WORKDIR}"/syweb/{CHANGELOG,README} || die "dodoc syweb failed"

		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/* || die "doins syweb failed"
		webapp_configfile "${MY_HTDOCSDIR}"/setup.inc

		webapp_src_install
	fi
}

pkg_postinst() {
	elog "Before running the monitor, edit /etc/symon.conf. To test your"
	elog "configuration file, run symon -t."
	elog "NOTE that symon won't chroot by default."

	use perl && perl-module_pkg_postinst

	if use symux ; then
		elog "Before running the data collector, edit /etc/symux.conf."
		elog "To create the RRDs run /usr/share/symon/c_smrrds.sh all. Then,"
		elog "to test your configuration file, run symux -t."
		elog "For information about migrating RRDs from a previous symux"
		elog "version read the LEGACY FORMATS section of symux(8)."
	fi

	if use syweb ; then
		elog "Test your syweb configuration by pointing your browser at:"
		elog "http://${VHOST_HOSTNAME}/${PN}/configtest.php"
		elog "Customize syweb by editing the file setup.inc."
		elog "If you don't want any user interaction, move index_noui.php"
		elog "to index.php."
		elog "NOTE that syweb expects a machine/*.rrd style directory"
		elog "structure under /var/lib/symon/rrds."
		webapp_pkg_postinst
	fi
}

pkg_prerm() {
	use syweb && webapp_pkg_prerm
}