Name:           monit
Version:        5.2.5
Release:        1%{?_dist_release}
Summary:        Manages and monitors processes, files, directories and devices
Summary(ja):    プロセス/ファイル/ディレクトリ/デバイスを監視するツール

Group:          Applications/Internet
License:        GPLv3+
URL:            http://www.tildeslash.com/monit
Source0:        http://www.tildeslash.com/monit/dist/monit-%{version}.tar.gz
Source1:        monit-sysv-initscript
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

BuildRequires:  flex
BuildRequires:  openssl-devel
BuildRequires:  byacc

Requires(post): /sbin/chkconfig
Requires(preun): /sbin/chkconfig
Requires(preun): /sbin/service
Requires(postun): /sbin/service

%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.

%description -l ja
monit は、UNIX システム上でプロセス、ファイル、ディレクトリ、デバイスなどを
監視・管理するためのユーティリティです。monit を使うと、メンテナンスや復旧を
自動で行うことができ、エラーが発生した時にそれに対応するアクションを実行する
ことができます。


%prep
%setup -q


%build
%configure \
    --disable-static
make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
# overwrite perms
%{__install} -p -D -m0755 monit $RPM_BUILD_ROOT%{_bindir}/monit

%{__install} -p -D -m0755 %{SOURCE1} $RPM_BUILD_ROOT%{_initrddir}/monit
%{__install} -p -D -m0600 monitrc $RPM_BUILD_ROOT%{_sysconfdir}/monit.conf


%clean
rm -rf $RPM_BUILD_ROOT


%post
# This adds the proper /etc/rc*.d links for the script
/sbin/chkconfig --add monit

%preun
if [ $1 = 0 ]; then
        /sbin/service monit stop >/dev/null 2>&1
        /sbin/chkconfig --del monit
fi

%postun
if [ "$1" -ge "1" ]; then
        /sbin/service monit condrestart >/dev/null 2>&1 || :
fi


%files
%defattr(-,root,root,-)
%doc CHANGES.txt CONTRIBUTORS COPYING FAQ.txt LICENSE PLATFORMS README README.DEVELOPER README.SSL STATUS UPGRADE.txt 
%doc %{_mandir}/man1/monit.1*
%config(noreplace) %{_sysconfdir}/monit.conf
%{_initrddir}/monit
%{_bindir}/%{name}


%changelog
* Wed Aug 10 2011 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 5.2.5-1
- new upstream release

* Sun Mar 20 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 5.2.4-1
- new upstream release

* Mon Nov 10 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 4.10.1-8
- initial build for Vine Linux

* Mon Feb 18 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 4.10.1-7
- Autorebuild for GCC 4.3

* Wed Dec 05 2007 Release Engineering <rel-eng at fedoraproject dot org> - 4.10.1-6
 - Rebuild for deps


* Wed Dec 5 2007 Stewart Adam <s.adam at diffingo.com> 4.10.1-5
- Rebuild to fix broken deps on libssl.so.6 and libcrypto.so.6

* Sat Nov 24 2007 Stewart Adam <s.adam at diffingo.com> 4.10.1-4
- Substitute RPM macros for their real values in monit.conf (#397671)

* Tue Nov 13 2007 Stewart Adam <s.adam at diffingo.com> 4.10.1-3
- Bump
- Fix changelog date for previous entry

* Mon Nov 12 2007 Stewart Adam <s.adam at diffingo.com> 4.10.1-2.1
- Switch back to OpenSSL since NSS isn't working too well with Monit

* Wed Nov 7 2007 Stewart Adam <s.adam at diffingo.com> 4.10.1-2
- License is actually GPLv3+
- s/%%{__install}/%%{__install} -p/
- NSS-ize

* Tue Nov 6 2007 Stewart Adam <s.adam at diffingo.com> 4.10.1-1
- Initial RPM release
