1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit cmake-utils depend.apache eutils systemd toolchain-funcs user versionator
8 DESCRIPTION="Distributed, general purpose, network monitoring engine"
9 HOMEPAGE="http://icinga.org/icinga2"
10 SRC_URI="https://github.com/Icinga/icinga2/archive/v${PV}.tar.gz -> ${P}.tar.gz"
14 KEYWORDS="~amd64 ~x86"
15 IUSE="+mysql postgres classicui minimal nano-syntax +plugins +vim-syntax"
21 >=sys-devel/flex-2.5.35
22 mysql? ( virtual/mysql )
23 postgres? ( dev-db/postgresql:= )"
28 net-analyzer/monitoring-plugins
29 net-analyzer/nagios-plugins
31 classicui? ( net-analyzer/icinga[web] )"
33 REQUIRED_USE="!minimal? ( || ( mysql postgres ) )"
40 enewgroup nagios # for plugins
41 enewuser icinga -1 -1 /var/lib/icinga2 "icinga,icingacmd,nagios"
45 # epatch "${FILESDIR}/${P}-create_var_cache.patch"
51 -DICINGA2_UNITY_BUILD=FALSE
52 -DCMAKE_VERBOSE_MAKEFILE=ON
53 -DCMAKE_BUILD_TYPE=None
54 -DCMAKE_INSTALL_PREFIX=/usr
55 -DCMAKE_INSTALL_SYSCONFDIR=/etc
56 -DCMAKE_INSTALL_LOCALSTATEDIR=/var
57 -DICINGA2_SYSCONFIGFILE=/etc/conf.d/icinga2
59 -DICINGA2_GROUP=icingacmd
60 -DICINGA2_COMMAND_USER=icinga
61 -DICINGA2_COMMAND_GROUP=icingacmd
62 -DINSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT=yes
66 -DICINGA2_WITH_MYSQL=OFF
67 -DICINGA2_WITH_PGSQL=OFF
72 -DICINGA2_WITH_PGSQL=ON
76 -DICINGA2_WITH_PGSQL=OFF
81 -DICINGA2_WITH_MYSQL=ON
85 -DICINGA2_WITH_MYSQL=OFF
88 cmake-utils_src_configure
92 BUILDDIR="${WORKDIR}"/icinga2-${PV}_build
95 #if [[ -f Makefile ]] || [[ -f GNUmakefile ]] || [[ -f makefile ]] ; then
97 emake DESTDIR="${D}" install
100 cd "${WORKDIR}"/icinga2-${PV}
101 if ! declare -p DOCS >/dev/null 2>&1 ; then
103 for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS \
104 FAQ CREDITS CHANGELOG ; do
105 [[ -s "${d}" ]] && dodoc "${d}"
107 elif declare -p DOCS | grep -q "^declare -a " ; then
113 newinitd "${FILESDIR}"/icinga2.initd icinga2
114 newconfd "${FILESDIR}"/icinga2.confd icinga2
118 newdoc "${WORKDIR}"/icinga2-${PV}/lib/db_ido_mysql/schema/mysql.sql mysql.sql
119 docinto schema/upgrade
120 #newdoc "${WORKDIR}"/icinga2-${PV}/components/db_ido_mysql/schema/upgrade/0.0.11.sql mysql-upgrade-1.12.0.sql
121 elif use postgres ; then
123 newdoc "${WORKDIR}"/icinga2-${PV}/lib/db_ido_pgsql/schema/pgsql.sql pgsql.sql
124 docinto schema/upgrade
125 #newdoc "${WORKDIR}"/icinga2-${PV}/components/db_ido_pgsql/schema/upgrade/0.0.11.sql pgsql-upgrade-1.12.0.sql
129 keepdir /var/lib/icinga2/api/zones
130 keepdir /var/lib/icinga2/api/repository
131 keepdir /var/lib/icinga2/api/log
132 keepdir /var/spool/icinga2/perfdata
134 rm -r "${D}var/run" || die "failed to remove /var/run"
135 rm -r "${D}var/cache" || die "failed to remove /var/cache"
137 fowners icinga:icinga /etc/icinga2
138 fowners icinga:icinga /var/lib/icinga2
139 fowners icinga:icinga /var/spool/icinga2
140 fowners icinga:icinga /var/spool/icinga2/perfdata
141 fowners icinga:icingacmd /var/log/icinga2
143 fperms ug+rwX,o-rwx /etc/icinga2
144 fperms ug+rwX,o-rwx /var/lib/icinga2
145 fperms ug+rwX,o-rwx /var/spool/icinga2
146 fperms ug+rwX,o-rwx /var/log/icinga2
148 if use vim-syntax; then
149 insinto /usr/share/vim/vimfiles
150 doins -r tools/syntax/vim/ftdetect
151 doins -r tools/syntax/vim/syntax
154 if use nano-syntax; then
155 insinto /usr/share/nano
156 doins tools/syntax/nano/icinga2.nanorc
161 elog "DB IDO schema upgrade required. http://docs.icinga.org/icinga2/snapshot/chapter-2.html#upgrading-the-mysql-database"
162 elog "You will need to update your configuration files, see https://dev.icinga.org/issues/5909"