blob: c2e38f99e586159bb012fb32b02f63e95cd8966f (
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=5
inherit depend.php subversion webapp
DESCRIPTION="Observium is an autodiscovering SNMP based network monitoring platform"
HOMEPAGE="http://www.observium.org/"
PREV="${PV}"
ESVN_REPO_URI="http://www.observium.org/svn/observer/trunk@${PREV}"
LICENSE="QPL-1.0"
SLOT="0"
KEYWORDS="~x86 ~amd64"
IUSE="+examples ipmi libvirt +mibs tools +web"
HDEPEND="
sys-apps/coreutils
sys-apps/findutils
sys-apps/sed
"
DEPEND=""
RDEPEND="${DEPEND}
>=net-analyzer/net-snmp-5.4
>=net-analyzer/rrdtool-1.3
>=virtual/httpd-php-5.3
virtual/cron
dev-php/PEAR-Net_IPv4
dev-php/PEAR-Net_IPv6
net-analyzer/fping
media-fonts/dejavu
media-gfx/graphviz
media-gfx/imagemagick
net-analyzer/mtr
net-analyzer/nmap
net-misc/whois
ipmi? ( sys-apps/ipmitool )
libvirt? ( app-emulation/libvirt )
tools? (
dev-lang/python
dev-python/mysql-python
)
"
WEBAPP_MANUAL_SLOT="yes"
function get_stable_revision() {
if getent hosts www.observium.org >/dev/null 2>&1; then
if type -pf curl >/dev/null 2>&1; then
curl http://www.observium.org/stable.php
return 0
fi
fi
return 1
}
pkg_pretend() {
local result
VERSION="$( get_stable_revision )"
result=$?
if [[ -n "$VERSION" ]] && ! (( result )); then
if ! [[ "$VERSION" == "$PREV" ]]; then
ewarn "This ebuild is for ${PN} revision ${PREV} - the current" \
"stable release is revision ${VERSION}."
else
einfo "Release ${VERSION} is the current stable release"
fi
fi
}
pkg_setup() {
webapp_pkg_setup
require_php_with_use cli cgi mysql gd snmp
}
src_prepare() {
epatch "${FILESDIR}"/"${PF}"-version.patch || \
die "epatch for version failed"
use mibs || rm -r "${S}"/mibs
}
src_install() {
use web && webapp_src_preinst
# Install non-webapp binaries to /usr/share/observium...
insinto /usr/share/${PN}
# Prune an unused directory...
[[ -d scripts/agent-local/munin-scripts ]] \
&& rmdir scripts/agent-local/munin-scripts 2>/dev/null
doins -r attic contrib scripts upgrade-scripts
find "${ED}"/usr/share/"${PN}"/ -type f -not \( \
-name README -or -name \*.cnf -or -name \*.conf -or -name \*.inc.php \
\) -print | while read FILE; do
fperms 0755 "$( sed "s|${ED}||" <<<"$FILE" )"
done
use mibs && [[ -d mibs ]] && doins -r mibs
# Install configuration examples...
if use examples; then
dodoc "${FILESDIR}"/observium.lighttpd
dodoc "${FILESDIR}"/observium.apache
dodoc *.example
fi
if use web; then
insinto "${MY_HTDOCSDIR}"/
doins config.php.default *.php
use tools && doins poller-wrapper.py
doins -r html includes sql-schema
mv "${ED}/${MY_HTDOCSDIR}"/config.php.default "${ED}/${MY_HTDOCSDIR}"/config.php
webapp_configfile ${MY_HTDOCSDIR}/config.php
for DIR in graphs logs rrd tmp; do
mkdir "${ED}/${MY_HTDOCSDIR}"/${DIR}
webapp_serverowned "${MY_HTDOCSDIR}"/${DIR}
done
use mibs \
&& dosym /usr/share/"${PN}"/mibs "${MY_HTDOCSDIR}"/mibs
# Create appropriate cron.d entry...
dodir /etc/cron.d/
use tools && SCRIPT="poller-wrapper.py 1" || SCRIPT="poller.php -h all"
[[ -n "${EROOT}" && "${EROOT}" != "/" ]] \
&& LOC="\"${EROOT}\"/var/www/localhost/htdocs" \
|| LOC="/var/www/localhost/htdocs"
# Ideally, this would be performed as the appropriate web-server user
# (lighttpd, nginx, apache, etc.)...
cat >"${ED}"/etc/cron.d/${PN} <<EOF
33 */6 * * * root test -x ${LOC}/"${PN}"/discovery.php && ${LOC}/"${PN}"/discovery.php -h all >/dev/null 2>&1
*/5 * * * * root test -x ${LOC}/"${PN}"/discovery.php && ${LOC}/"${PN}"/discovery.php -h new >/dev/null 2>&1
*/5 * * * * root test -x ${LOC}/"${PN}"/${SCRIPT} && ${LOC}/"${PN}"/${SCRIPT} >/dev/null 2>&1
EOF
webapp_postinst_txt en "${FILESDIR}"/postinstall-en-${PV}.txt
webapp_src_install
for FILE in discovery.php addhost.php adduser.php \
includes/sql-schema/update.php; do
fperms 0755 "${MY_HTDOCSDIR}"/"$FILE"
done
fi
}
pkg_postinst() {
use web && ! use mibs && ewarn \
"You have chosen not to install Observium MIBs - you *must* copy" \
"(or create a symlink to) a directory containing MIB files" \
"as '${VHOST_ROOT}/htdocs/${PN}/mibs'."
[[ -n "${EROOT}" && "${EROOT}" != "/" ]] \
&& LOC="\"${EROOT}\"/usr/share/doc/${PF}" \
|| LOC="/usr/share/doc/${PF}"
einfo "Example configuration files for Apache and lighttpd have been" \
"installed to '$LOC'."
ewarn "For security reasons, you may wish to edit /etc/cron.d/${PN}" \
"and change the discovery and poll processes to run as your webserver" \
"user (e.g. lighttpd, nginx, or apache) rather than 'root'."
}
|