# Copyright (C) 2008 Platform Computing Inc # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # # %define COMP1 component-nagios-installer-v2_12 %define COMP2 component-nagios-compute-v2_12 %define _name nagios %define subversion 3 Summary: Nagios(R) Kit Name: kit-nagios Version: 2.12 Release: 5 License: GPLv2 Group: System Environment/Base Vendor: Platform Computing Inc BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot BuildArch: noarch Source: kit-nagios-%{version}.%{subversion}.tar.gz Requires: shadow-utils Requires: component-base-installer Requires: glibc-common URL: http://www.platform.com %define SQLRUNNER /opt/kusu/sbin/sqlrunner %description This package is destined for the installer node and serves as an information container for the database for the Nagios(R) kit %prep %setup -q -n %{_name} %build %install rm -rf $RPM_BUILD_ROOT # Plugins install -d $RPM_BUILD_ROOT/plugins/addhost install -d $RPM_BUILD_ROOT/plugins/ngedit install -m 755 plugins/addhost/16-nagios_2_12.py $RPM_BUILD_ROOT/plugins/addhost install -m 755 plugins/ngedit/00-component-nagios-installer-v2_12.py $RPM_BUILD_ROOT/plugins/ngedit # Documentation install -d $RPM_BUILD_ROOT/www/kit_nagios_doc_source install -m 444 docs/index.html $RPM_BUILD_ROOT/www install -m 444 docs/readme.html $RPM_BUILD_ROOT/www install -m 444 docs/COPYING $RPM_BUILD_ROOT/www install -m 444 docs/kit_nagios_doc_source/* -t $RPM_BUILD_ROOT/www/kit_nagios_doc_source # Kitinfo file install -m 644 kitinfo $RPM_BUILD_ROOT/kitinfo %clean rm -rf $RPM_BUILD_ROOT %files # Plugins /plugins/addhost/16-nagios_2_12.py* /plugins/ngedit/00-component-nagios-installer-v2_12.py* # Documentation %dir /www/kit_nagios_doc_source /www/index.html /www/readme.html /www/COPYING /www/kit_nagios_doc_source/* # Kitinfo file /kitinfo %pre %post PATH=$PATH:/opt/kusu/sbin export PATH if [ -d /opt/kusu/lib ]; then PYTHONPATH=/opt/kusu/lib64/python:/opt/kusu/lib/python: else PYTHONPATH=FIX_ME fi export PYTHONPATH # Make the component entries because kitops is broken!!! KID=`%{SQLRUNNER} -q "SELECT kid FROM kits WHERE rname='nagios' and version='%{version}'"` if [ $? -ne 0 ]; then exit 0 fi # Set the kit to be proper arch # Setup the kit #%{SQLRUNNER} -q "UPDATE kits SET arch='%{_arch}' WHERE rname='nagios'" %{SQLRUNNER} -q "DELETE FROM components WHERE kid=$KID" %{SQLRUNNER} -q "INSERT into components (cname, cdesc, kid, os) VALUES ('%{COMP1}', 'Nagios Installer', $KID, 'rhel-5-x86_64')" %{SQLRUNNER} -q "INSERT into components (cname, cdesc, kid, os) VALUES ('%{COMP1}', 'Nagios Installer', $KID, 'centos-5-x86_64')" %{SQLRUNNER} -q "INSERT into components (cname, cdesc, kid, os) VALUES ('%{COMP1}', 'Nagios Installer', $KID, 'rhel-5-i386')" %{SQLRUNNER} -q "INSERT into components (cname, cdesc, kid, os) VALUES ('%{COMP1}', 'Nagios Installer', $KID, 'centos-5-i386')" %{SQLRUNNER} -q "INSERT into components (cname, cdesc, kid, os) VALUES ('%{COMP2}', 'Nagios Compute Node', $KID, 'rhel-5-x86_64')" %{SQLRUNNER} -q "INSERT into components (cname, cdesc, kid, os) VALUES ('%{COMP2}', 'Nagios Compute Node', $KID, 'centos-5-x86_64')" %{SQLRUNNER} -q "INSERT into components (cname, cdesc, kid, os) VALUES ('%{COMP2}', 'Nagios Compute Node', $KID, 'rhel-5-i386')" %{SQLRUNNER} -q "INSERT into components (cname, cdesc, kid, os) VALUES ('%{COMP2}', 'Nagios Compute Node', $KID, 'centos-5-i386')" CID1=`%{SQLRUNNER} -q "SELECT cid from components where kid=$KID and cname='%{COMP1}' and os=(select repos.ostype from repos, nodegroups WHERE nodegroups.ngid=1 AND nodegroups.repoid=repos.repoid)"` if [ "x$CID1" = "x" ]; then # The kit provides components that are not used with the installers OS# exit 0 fi CID2=`%{SQLRUNNER} -q "SELECT cid from components where kid=$KID and cname='%{COMP2}' and os=(select repos.ostype from repos, nodegroups WHERE nodegroups.ngid=1 AND nodegroups.repoid=repos.repoid)"` # SQL/Shell/Python code to update the database.. The updates may optionally # include Node group creation and component association - Installer only by default %{SQLRUNNER} -q "INSERT INTO ng_has_comp (ngid, cid) VALUES (1, $CID1)" %{SQLRUNNER} -q "INSERT INTO ng_has_comp (ngid, cid) VALUES (2, $CID2)" # Add in nagios server to appglobals table, first get interface SERVER_IP=`%{SQLRUNNER} -q "SELECT ip from nics, nodes, networks WHERE nics.netid=networks.netid AND nodes.nid=nics.nid AND nodes.name=(SELECT kvalue FROM appglobals WHERE kname='PrimaryInstaller') AND networks.type = 'provision'"` %{SQLRUNNER} -q "INSERT INTO appglobals (kname, kvalue) VALUES ('NagiosServers', '$SERVER_IP')" %preun # PREUN section # Test the database connection before allowing the package to be removed PATH=$PATH:/opt/kusu/sbin export PATH if [ -d /opt/kusu/lib ]; then PYTHONPATH=/opt/kusu/lib64/python:/opt/kusu/lib/python: else PYTHONPATH=FIX_ME fi export PYTHONPATH %{SQLRUNNER} -q "DELETE FROM appglobals WHERE kname = 'NagiosServers'" KID=`%{SQLRUNNER} -q "SELECT kid FROM kits WHERE rname='nagios' and version='%{version}'"` if [ $? -ne 0 ]; then echo "Database is down. Unable to remove kit." exit 1 fi %postun # POSTUN section rm -rf /opt/kusu/lib/plugins/addhost/16-nagios_2_12.py* rm -rf /opt/kusu/lib/plugins/ngedit/00-component-nagios-installer-v2_12.py* %changelog * Wed Jan 7 2009 Mark Black 2.12-5 - Added missing requirements for post section * Tue Nov 18 2008 Mark Black 2.13-4 - Fixes to support postgres * Wed Sep 25 2008 Mike Frisch 2.13-3 - Use static uid/gid when adding nagios user/group (#116132) * Tue May 27 2008 Shawn Starr 2.12-2 - Create user in case component is used on a different node group * Fri May 23 2008 Shawn Starr 2.12-1 - New release of Nagios. Fixes BZ #445512 * Mon May 12 2008 Shawn Starr 2.11-1 - New release of Nagios * Mon May 12 2008 Mike Frisch 2.10-4 - Fix "database user to root escalation" issue (#108337) * Thu Mar 20 2008 Mike Frisch 2.10-3 - Removed AutoReq tag at the request of Red Hat * Thu Mar 20 2008 Mike Frisch 2.10-2 - Change location of Kusu installer lock file