File monit.spec of Package monit

#
# spec file for package monit
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/
#

# norootforbuild


Name:           monit
Version:        5.3.1
Release:        1
Summary:        Service Manager and Monitor System
# http://mmonit.com/monit/dist/monit-%{version}.tar.gz
Source:         monit-%{version}.tar.bz2
Source1:        monit-vendor-files.tar.gz
Patch1:         monit-page_shift.patch
Url:            http://mmonit.com/monit/download/
Group:          System/Monitoring
License:        GNU General Public License (GPL)
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  bison flex gcc glibc-devel make openssl-devel
BuildRequires:  autoconf automake libtool
Obsoletes:      monit-beta < %{version}
Provides:       monit-beta = %{version}
%if "%{_vendor}" == "suse"
%define VENDOR SUSE
%else
%define VENDOR %_vendor
%endif

%description
Monit is a utility for managing and monitoring processes, files,
directories, and devices on a Unix system.  Monit conducts automatic
maintenance and repair and can execute meaningful causal actions in
error situations.  For example, monit can start a process if it does
not run, restart a process if it does not respond, and stop a process
if it uses too many resources.	You can use monit to monitor files,
directories, and devices for changes, such as time stamp changes,
checksum changes, or size changes. You can even use monit to monitor
remote hosts: monit can ping a remote host and check port connections.

%package doc
License:        GNU General Public License (GPL)
Summary:        Service Manager and Monitor System (Documentation and Examples)
Group:          System/Monitoring
%if 0%{?suse_version} >= 1120
BuildArch:      noarch
%endif

%description doc
Monit is a utility for managing and monitoring processes, files,
directories, and devices on a Unix system.  Monit conducts automatic
maintenance and repair and can execute meaningful causal actions in
error situations.  For example, monit can start a process if it does
not run, restart a process if it does not respond, and stop a process
if it uses too many resources.	You can use monit to monitor files,
directories, and devices for changes, such as time stamp changes,
checksum changes, or size changes. You can even use monit to monitor
remote hosts: monit can ping a remote host and check port connections.

This package only contains the documentation and examples.
You must also install the package %{name} to actually use monit.

%prep
%setup -q -a1
%patch1

find doc/ -type f -size 0 -exec %__rm {} \;

%build
export CFLAGS="%{optflags} -fno-strict-aliasing"
%configure \
	--with-ssl-lib-dir="%{_libdir}"

%__make %{?_smp_flags}

%install
%__make DESTDIR="%{buildroot}" install

%__install -d \
	"%{buildroot}/etc/init.d" \
	"%{buildroot}%{_sysconfdir}/monit.d" \
	"%{buildroot}%{_sbindir}" \
	"%{buildroot}%{_datadir}/monit" \
	"%{buildroot}%{_var}/adm/fillup-templates" \
	"%{buildroot}%{_var}/run/monit" \
	"%{buildroot}%{_var}/lib/monit"

. vendor-files/sysconfig/monit.tmpl
MONIT_BIN="%{_bindir}/monit"
MONIT_MODIFY_INITTAB="%{_datadir}/monit/monit-modifyinittab"
MONIT_PID_FILE="%{_var}/run/monit/monit.pid"
MONIT_SYSCONFIG_FILE="/etc/sysconfig/monit"
MONIT_INITTAB_STATE_FILE="%{_var}/lib/monit/monit-inittab.state"
MONIT_ARGS="-p ${MONIT_PID_FILE} -s %{_var}/run/monit/monit.state"
MONIT_EVENTQUE_DIR="%{_var}/lib/monit"
%__sed -e "s|%{_var}/monit|${MONIT_EVENTQUE_DIR}|g" \
	< monitrc > "%{buildroot}%{_sysconfdir}/monitrc"

pushd vendor-files
for templatefile in docu/README tools/monit-modifyinittab init/monit sysconfig/monit; do
	%__sed \
		-e "s|__MONIT_RC_FILE__|${MONIT_RC_FILE}|g" \
		-e "s|__MONIT_INITTAB_BASE__|${MONIT_INITTAB_BASE}|g" \
		-e "s|__MONIT_INITTAB_COMMENT__|${MONIT_INITTAB_COMMENT}|g" \
		-e "s|__MONIT_INITTAB_STATE_FILE__|${MONIT_INITTAB_STATE_FILE}|g" \
		-e "s|__MONIT_ARGS__|${MONIT_ARGS}|g" \
		-e "s|__MONIT_BIN__|${MONIT_BIN}|g" \
		-e "s|__MONIT_MODIFY_INITTAB__|${MONIT_MODIFY_INITTAB}|g" \
		-e "s|__MONIT_PID_FILE__|${MONIT_PID_FILE}|g" \
		-e "s|__MONIT_SYSCONFIG_FILE__|${MONIT_SYSCONFIG_FILE}|g" \
		< "${templatefile}.tmpl" \
		> "${templatefile}"
done
popd # vendor-files

%__install -m0754 vendor-files/init/monit "%{buildroot}/etc/init.d/monit"
%__ln_s ../../etc/init.d/monit "%{buildroot}/usr/sbin/rcmonit"
%__install -m0754 vendor-files/tools/monit-modifyinittab "%{buildroot}%{_datadir}/monit"
%__install -m0644 vendor-files/sysconfig/monit "%{buildroot}%{_var}/adm/fillup-templates/sysconfig.monit"
touch "%{buildroot}%{_var}/lib/monit/monit-inittab.state"
touch "%{buildroot}%{_var}/run/monit"/monit.{pid,state}
%__install -m0644 vendor-files/docu/README README.SUSE

%__install -d "%{buildroot}%{_docdir}/%{name}"
>doc.main.lst
for f in COPYING; do
    %__install -m0644 "$f" "%{buildroot}%{_docdir}/%{name}/$f"
    echo "%doc %{_docdir}/%{name}/$f" >>doc.main.lst
done
>doc.doc.lst
for f in CHANGES README* doc; do
    %__cp -a "$f" "%{buildroot}%{_docdir}/%{name}/"
    echo "%doc %{_docdir}/%{name}/$(basename $f)" >>doc.doc.lst
done

%post
%{fillup_and_insserv}

%preun
%{stop_on_removal monit}

%postun
%{restart_on_update monit}
%{insserv_cleanup}

%clean
%__rm -rf "%{buildroot}"

%files -f doc.main.lst
%defattr(-,root,root)
%doc %dir %{_docdir}/%{name}
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/monitrc
%dir %{_sysconfdir}/monit.d
%attr(0754,root,root) %config /etc/init.d/monit
/usr/sbin/rcmonit
%{_bindir}/monit
%dir %{_datadir}/monit
%{_datadir}/monit/monit-modifyinittab
%{_var}/adm/fillup-templates/sysconfig.monit
%dir %{_var}/lib/monit
%ghost %{_var}/lib/monit/monit-inittab.state
%ghost %dir %{_var}/run/monit
%ghost %{_var}/run/monit/monit.pid
%ghost %{_var}/run/monit/monit.state
%doc %{_mandir}/man1/monit.1%{ext_man}

%files doc -f doc.doc.lst
%defattr(-,root,root)
%doc %dir %{_docdir}/%{name}

%changelog
openSUSE Build Service is sponsored by