-install -d $RPM_BUILD_ROOT{/etc/cron.hourly,%{_bindir}} \
- $RPM_BUILD_ROOT%{_datadir}/awstats/{lang,lib,plugins/example} \
- $RPM_BUILD_ROOT%{wwwdir}/{cgi-bin,html/icon/{browser,clock,cpu,flags,mime,os,other}}
+install -d $RPM_BUILD_ROOT{%{_sysconfdir}/{httpd,cron.d},%{_sysconfdir}/awstats,%{_bindir}} \
+ $RPM_BUILD_ROOT{%{_datadir}/awstats,/var/lib/awstats}
+
+install tools/awstats_* $RPM_BUILD_ROOT%{_bindir}
+install tools/{logresolvemerge,maillogconvert,urlaliasbuilder}.pl $RPM_BUILD_ROOT%{_bindir}
+cp -r wwwroot $RPM_BUILD_ROOT%{_datadir}/awstats
+mv $RPM_BUILD_ROOT%{_datadir}/awstats/wwwroot/cgi-bin/awstats.model.conf $RPM_BUILD_ROOT%{_sysconfdir}/awstats
+mv $RPM_BUILD_ROOT%{_datadir}/awstats/wwwroot/cgi-bin/{lang,lib,plugins} $RPM_BUILD_ROOT%{_datadir}/%{name}
+install %{SOURCE1} $RPM_BUILD_ROOT/etc/cron.d/awstats
+install %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/httpd/%{name}.conf
+install %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/%{name}/%{name}.conf
+ln -s %{_datadir}/awstats/wwwroot/cgi-bin/awstats.pl $RPM_BUILD_ROOT%{_bindir}
+
+%post
+if [ -f /etc/httpd/httpd.conf ] && ! grep -q "^Include.*/%{name}.conf" /etc/httpd/httpd.conf; then
+ echo "Include /etc/httpd/%{name}.conf" >> /etc/httpd/httpd.conf
+ if [ -f /var/lock/subsys/httpd ]; then
+ /etc/rc.d/init.d/httpd restart 1>&2
+ fi
+elif [ -d /etc/httpd/httpd.conf ]; then
+ ln -sf /etc/httpd/%{name}.conf /etc/httpd/httpd.conf/99_%{name}.conf
+ if [ -f /var/lock/subsys/httpd ]; then
+ /etc/rc.d/init.d/httpd restart 1>&2
+ fi
+fi