+# TODO
+# - strange error when accessing "/~watch-info":
+# [Thu Feb 10 03:16:16 2005] [warn] " 1\n\b" concurrency counter went negative; resetting to zero
+
+%bcond_without ipv6 # disable IPv6 support
+
%define mod_name watch
-%define apxs /usr/sbin/apxs
+%define apxs /usr/sbin/apxs1
Summary: Apache module: Monitoring Interface for MRTG
Summary(pl): ModuĀ³ do apache: Interfejs do monitorowania za pomocĀ± MRTG
-Name: apache-mod_%{mod_name}
-Version: 3.12
-Release: 1
+Name: apache1-mod_%{mod_name}
+Version: 3.18
+Release: 1.2
License: BSD
Group: Networking/Daemons
-Source0: http://www.snert.com/Software/mod_watch/mod_watch%(echo %{version} | sed -e "s#\.##g").tgz
+Source0: http://www.snert.com/Software/download/mod_watch%(echo %{version} | tr -d .).tgz
+# Source0-md5: 1409df800f24214bed16ca753b9967ff
Source1: %{name}.conf
+Patch0: %{name}-PLD-v6stuff.patch
URL: http://www.snert.com/Software/mod_watch/
BuildRequires: %{apxs}
-BuildRequires: apache(EAPI)-devel
-Prereq: %{_sbindir}/apxs
-Requires: apache(EAPI)
+BuildRequires: apache1-devel >= 1.3.33-2
+%{?with_ipv6:BuildRequires: apache1(ipv6)-devel}
+Requires(post,preun): %{apxs}
+Requires(post,preun): grep
+Requires(preun): fileutils
+Requires: apache1 >= 1.3.33-2
+Obsoletes: apache-mod_%{mod_name} <= %{version}
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
-%define _pkglibdir %(%{apxs} -q LIBEXECDIR)
-%define _sysconfdir /etc/httpd
+%define _pkglibdir %(%{apxs} -q LIBEXECDIR 2>/dev/null)
+%define _sysconfdir %(%{apxs} -q SYSCONFDIR 2>/dev/null)
%description
This module will watch and collect the bytes, requests, and documents
%prep
%setup -q -n mod_%{mod_name}-%{version}
+%{?with_ipv6:%patch -p0}
+
+mv mod_watch.html mod_watch_pl.html
%build
-%{__make} build-dynamic
+%{__make} build-dynamic \
+ APXS=%{apxs}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_pkglibdir},%{_sysconfdir}}
+install -d $RPM_BUILD_ROOT{%{_pkglibdir},%{_sysconfdir}/conf.d}
install mod_%{mod_name}.so $RPM_BUILD_ROOT%{_pkglibdir}
-install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/mod_watch.conf
+install %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/conf.d/90_mod_%{mod_name}.conf
-gzip -9nf CHANGES* apache2mrtg*
+sed -e 's/<!--#/<!--/g' index.shtml > mod_watch.html
+
+%clean
+rm -rf $RPM_BUILD_ROOT
%post
-%{_sbindir}/apxs -e -a -n %{mod_name} %{_pkglibdir}/mod_%{mod_name}.so 1>&2
-if [ -f /etc/httpd/httpd.conf ] && ! grep -q "^Include.*mod_watch.conf" /etc/httpd/httpd.conf; then
- echo "Include /etc/httpd/mod_watch.conf" >> /etc/httpd/httpd.conf
-fi
-if [ -f /var/lock/subsys/httpd ]; then
- /etc/rc.d/init.d/httpd restart 1>&2
+if [ -f /var/lock/subsys/apache ]; then
+ /etc/rc.d/init.d/apache restart 1>&2
+else
+ echo "Run \"/etc/rc.d/init.d/apache start\" to start apache HTTP daemon."
fi
%preun
if [ "$1" = "0" ]; then
- %{_sbindir}/apxs -e -A -n %{mod_name} %{_pkglibdir}/mod_%{mod_name}.so 1>&2
- grep -v "^Include.*mod_watch.conf" /etc/httpd/httpd.conf > \
- /etc/httpd/httpd.conf.tmp
- mv -f /etc/httpd/httpd.conf.tmp /etc/httpd/httpd.conf
- if [ -f /var/lock/subsys/httpd ]; then
- /etc/rc.d/init.d/httpd restart 1>&2
+ if [ -f /var/lock/subsys/apache ]; then
+ /etc/rc.d/init.d/apache restart 1>&2
fi
fi
-%clean
-rm -rf $RPM_BUILD_ROOT
+%triggerpostun -- %{name} < 3.18-1.1
+if grep -q '^Include conf\.d' /etc/apache/apache.conf; then
+ %{apxs} -e -A -n %{mod_name} %{_pkglibdir}/mod_%{mod_name}.so 1>&2
+ sed -i -e '
+ /^Include.*mod_%{mod_name}\.conf/d
+ ' /etc/apache/apache.conf
+else
+ # they're still using old apache.conf
+ sed -i -e '
+ s,^Include.*mod_%{mod_name}\.conf,Include %{_sysconfdir}/conf.d/*_mod_%{mod_name}.conf,
+ ' /etc/apache/apache.conf
+fi
+if [ -f /var/lock/subsys/apache ]; then
+ /etc/rc.d/init.d/apache restart 1>&2
+fi
%files
%defattr(644,root,root,755)
-%doc *.gz *htm
+%doc CHANGES* *.html
+%attr(640,root,root) %config(noreplace) %verify(not size mtime md5) %{_sysconfdir}/conf.d/*_mod_%{mod_name}.conf
%attr(755,root,root) %{_pkglibdir}/*