./configure --prefix=/opt/software/nagios --exec-prefix=/opt/software/bin/ --with-nagios-user=mycustomuser --with-nagios-group=apache --with-command-user=myuser --with-command-group=apache
Все прекрасно, все работает. Но по скольку серверов там много, есть сильное желание собрать бинарный rpm пакет, где бы все уже было собрано так как надо.
Я скачал srpm файл отсюда - http://apt.sw.be/redhat/el5/en/source/nagi...1-5.el5.src.rpm
установил, отредактировал кусок в секции
Код:
%configure \
--prefix=/opt/software/nagios
# --datadir="%{_datadir}/nagios" \
# --libexecdir="%{_libdir}/nagios/plugins" \
# --localstatedir="%{_localstatedir}/nagios" \
# --with-checkresult-dir="%{_localstatedir}/nagios/spool/checkresults" \
# --sbindir="%{_libdir}/nagios/cgi" \
# --sysconfdir="%{_sysconfdir}/nagios" \
--with-cgiurl="/nagios/cgi-bin" \
--with-command-user="myuser" \
--with-command-group="apache" \
--with-gd-lib="%{_libdir}" \
--with-gd-inc="%{_includedir}" \
--with-htmurl="/nagios" \
# --with-init-dir="%{_initrddir}" \
--with-lockfile="%{_localstatedir}/nagios/nagios.pid" \
--with-mail="/bin/mail" \
--with-nagios-user="mycustom user" \
--with-nagios-group="apache" \
--enable-embedded-perl \
--with-perlcache \
--with-template-objects \
--with-template-extinfo \
--enable-event-broker
однако похоже, что не все изменения, которые я вношу работают. Если я меняю там что-либо с дефолтного значения на не дефолтное, то при попытке собрать пакет все вываливается с ошибкой:
Код:
*** Configuration summary for nagios 3.2.1 03-09-2010 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /opt/software/nagios
Lock file: /var/nagios.lock
Check result directory: /var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
+ --with-cgiurl=/nagios/cgi-bin --with-command-user=myuser --with-command-group=apache --with-gd-lib=/usr/lib64 --with-gd-inc=/usr/include --with-htmurl=/nagios
/var/tmp/rpm-tmp.21174: line 61: --with-cgiurl=/nagios/cgi-bin: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.21174 (%build)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.21174 (%build)
В тексте ошибки видно, что configure отработал с дефолтными опциями, а не с теми, что я ему передаю (видно по Nagios executable: nagios, Nagios user/group: nagios,nagios например). Однако при этом Install ${prefix}: /opt/software/nagios все-таки поменялся.
Где моя ошибка и как мне передать скрипту configure кастомные параметры?
ps RPM собираю 1й раз в жизни
pps пробовал проделать тоже самое с mc, там меняя эти параметры мне без проблем собрать пакет, который ставит его в /opt/
на всякий случай привожу целиком spec файл от nagios отредактированного мной в секции %configure:
Код:
# $Id: nagios.spec 8907 2010-06-18 17:50:38Z cmr $
# Authority: dag
# Upstream: Ethan Galstad <nagios$nagios,org>
### FIXME: TODO: Add sysv script based on template. (remove cmd-file on start-up)
%define logmsg logger -t %{name}/rpm
%define logdir %{_localstatedir}/log/nagios
Summary: Open Source host, service and network monitoring program
Name: nagios
Version: 3.2.1
Release: 5%{?dist}
License: GPL
Group: Applications/System
URL: http://www.nagios.org/
Packager: Dag Wieers <dag@wieers.com>
Vendor: Dag Apt Repository, http://dag.wieers.com/apt/
Source0: http://dl.sf.net/nagios/nagios-%{version}.tar.gz
Source1: http://dl.sf.net/nagios/imagepak-base.tar.gz
Source2: daemon-init-redhat.in
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires: gd-devel > 1.8
BuildRequires: zlib-devel
BuildRequires: libpng-devel
BuildRequires: libjpeg-devel
Obsoletes: nagios-www <= %{version}
Requires: httpd
Requires: php
%description
Nagios is an application, system and network monitoring application.
It can escalate problems by email, pager or any other medium. It is
also useful for incident or SLA reporting.
Nagios is written in C and is designed as a background process,
intermittently running checks on various services that you specify.
The actual service checks are performed by separate "plugin" programs
which return the status of the checks to Nagios. The plugins are
located in the nagios-plugins package.
%package devel
Summary: Header files, libraries and development documentation for %{name}
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description devel
This package contains the header files, static libraries and development
documentation for %{name}. If you like to develop programs using %{name},
you will need to install %{name}-devel.
%prep
%setup
# /usr/local/nagios is hardcoded in many places
%{__perl} -pi.orig -e 's|/usr/local/nagios/var/rw|%{_localstatedir}/nagios/rw|g;' contrib/eventhandlers/submit_check_result
# copy out init-script over the one provided by upstream
%{__cp} -f %{SOURCE2} daemon-init.in
%build
%configure \
%configure \
--prefix=/opt/software/nagios
# --datadir="%{_datadir}/nagios" \
# --libexecdir="%{_libdir}/nagios/plugins" \
# --localstatedir="%{_localstatedir}/nagios" \
# --with-checkresult-dir="%{_localstatedir}/nagios/spool/checkresults" \
# --sbindir="%{_libdir}/nagios/cgi" \
# --sysconfdir="%{_sysconfdir}/nagios" \
--with-cgiurl="/nagios/cgi-bin" \
--with-command-user="myuser" \
--with-command-group="apache" \
--with-gd-lib="%{_libdir}" \
--with-gd-inc="%{_includedir}" \
--with-htmurl="/nagios" \
# --with-init-dir="%{_initrddir}" \
--with-lockfile="%{_localstatedir}/nagios/nagios.pid" \
--with-mail="/bin/mail" \
--with-nagios-user="mycustom user" \
--with-nagios-group="apache" \
--enable-embedded-perl \
--with-perlcache \
--with-template-objects \
--with-template-extinfo \
--enable-event-broker
%{__make} %{?_smp_mflags} all
### Apparently contrib wants to do embedded-perl stuff as well and does not obey configure !
%{__make} %{?_smp_mflags} -C contrib
%install
%{__rm} -rf %{buildroot}
%{__make} install install-init install-commandmode install-config \
DESTDIR="%{buildroot}" \
INSTALL_OPTS="" \
COMMAND_OPTS="" \
INIT_OPTS=""
### Apparently contrib wants to do embedded-perl stuff as well and does not obey configure !
%{__make} install -C contrib \
DESTDIR="%{buildroot}" \
INSTALL_OPTS=""
%{__install} -d -m0755 %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/
%{__cp} -afpv contrib/eventhandlers/* %{buildroot}%{_libdir}/nagios/plugins/eventhandlers/
%{__install} -d -m0755 %{buildroot}%{_includedir}/nagios/
%{__install} -p -m0644 include/*.h %{buildroot}%{_includedir}/nagios/
%{__install} -Dp -m0644 sample-config/httpd.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/nagios.conf
### FIX log-paths
%{__perl} -pi -e '
s|log_file.*|log_file=%{logdir}/nagios.log|;
s|log_archive_path=.*|log_archive_path=%{logdir}/archives|;
s|debug_file=.*|debug_file=%{logdir}/nagios.debug|;
' %{buildroot}%{_sysconfdir}/nagios/nagios.cfg
### make logdirs
%{__mkdir} -p %{buildroot}%{logdir}/
%{__mkdir} -p %{buildroot}%{logdir}/archives/
### Install logos
%{__mkdir} -p %{buildroot}%{_datadir}/nagios/images/logos
tar -xvz -C %{buildroot}%{_datadir}/nagios/images/logos -f %{SOURCE1}
%pre
if ! /usr/bin/id nagios &>/dev/null; then
/usr/sbin/useradd -r -d %{logdir} -s /bin/sh -c "nagios" nagios || \
%logmsg "Unexpected error adding user \"nagios\". Aborting installation."
fi
if ! /usr/bin/getent group nagiocmd &>/dev/null; then
/usr/sbin/groupadd nagiocmd &>/dev/null || \
%logmsg "Unexpected error adding group \"nagiocmd\". Aborting installation."
fi
%post
/sbin/chkconfig --add nagios
if /usr/bin/id apache &>/dev/null; then
if ! /usr/bin/id -Gn apache 2>/dev/null | grep -q nagios ; then
/usr/sbin/usermod -a -G nagios,nagiocmd apache &>/dev/null
fi
else
%logmsg "User \"apache\" does not exist and is not added to group \"nagios\". Sending commands to Nagios from the command CGI is not possible."
fi
if [ -f %{_sysconfdir}/httpd/conf/httpd.conf ]; then
if ! grep -q "Include .*/nagios.conf" %{_sysconfdir}/httpd/conf/httpd.conf; then
echo -e "\n# Include %{_sysconfdir}/httpd/conf.d/nagios.conf" >> %{_sysconfdir}/httpd/conf/httpd.conf
# /sbin/service httpd restart
fi
fi
%preun
if [ $1 -eq 0 ]; then
/sbin/service nagios stop &>/dev/null || :
/sbin/chkconfig --del nagios
fi
%postun
if [ $1 -eq 0 ]; then
/usr/sbin/userdel nagios || %logmsg "User \"nagios\" could not be deleted."
/usr/sbin/groupdel nagios || %logmsg "Group \"nagios\" could not be deleted."
fi
/sbin/service nagios condrestart &>/dev/null || :
%clean
%{__rm} -rf %{buildroot}
%files
%defattr(-, root, root, 0755)
%doc Changelog INSTALLING LICENSE README UPGRADING
%config(noreplace) %{_sysconfdir}/httpd/conf.d/nagios.conf
%config %{_initrddir}/nagios
%{_bindir}/convertcfg
%attr(755,nagios,nagios) %{_bindir}/nagios
%{_bindir}/nagiostats
%{_bindir}/p1.pl
%{_bindir}/mini_epn
%{_bindir}/new_mini_epn
%{_libdir}/nagios/
%{_datadir}/nagios/
#%defattr(-, root, nagios, 0755)
#%config(noreplace) %{_sysconfdir}/nagios/private/
%defattr(-, nagios, nagios, 0755)
%dir %{_sysconfdir}/nagios/
%config(noreplace) %{_sysconfdir}/nagios/*.cfg
%config(noreplace) %{_sysconfdir}/nagios/objects
%{_localstatedir}/nagios/
%{_localstatedir}/nagios/spool/
%{logdir}/
%defattr(-, nagios, apache, 2755)
%{_localstatedir}/nagios/rw/
%files devel
%defattr(-, root, root, 0755)
%{_includedir}/nagios/
%changelog
* Fri Jun 18 2010 Christoph Maser <cmr@financial.com> - 3.2.1-5 - 8907/cmr
- Run configtest with correct user instead of root
- Use --user in init script call to daemon function
- Change owner of /usr/bin/nagios to nagios
* Wed Jun 02 2010 Christoph Maser <cmr@financial.com> - 3.2.1-4
- Add configtest to initscript
* Tue May 11 2010 Christoph Maser <cmr@financial.com> - 3.2.1-3
- Roll our own init-script
- Move pid file to a location where nagios user has access
* Fri May 07 2010 Yury V. Zaytsev <yury@shurup.com> - 3.2.1-2
- Fixed Apache group assignement (Catalin Bucur).
- Cleaned up old options.
* Sun Mar 21 2010 Dag Wieers <dag@wieers.com> - 3.2.1-1
- Updated to release 3.2.1.
* Thu Aug 12 2009 Christoph Maser <cmr$financial,com> - 3.2.0-1
- Updated to release 3.2.0.
* Mon Aug 03 2009 Christoph Maser <cmr$financial,com> - 3.1.2-1
- Updated to release 3.1.2.
* Mon Jan 26 2009 Christoph Maser <cmr$financial,com> - 3.1.0-1
- Updated to release 3.1.0.
* Thu Dec 02 2008 Christoph Maser <cmr$financial,com> - 3.0.6-1
- Updated to release 3.0.6.
* Thu Nov 06 2008 Christoph Maser <cmr$financial,com> - 3.0.5-1
- Updated to release 3.0.5.
* Tue Oct 21 2008 Christoph Maser <cmr$financial,com> - 3.0.4-1
- Updated to release 3.0.4.
* Wed Oct 10 2008 Christoph Maser <cmr$financial,com> - 3.0.3-1
- Updated to release 3.0.3.
- Set localstatedir to ${_localstatedir}.
- Because of the previous modify installed configs to put logs in %{logdir}.
* Thu May 22 2008 Dag Wieers <dag@wieers.com> - 2.12-1
- Updated to release 2.12.
...