install -m 0755 -d %{buildroot}%{_sysconfdir}/log.d/conf/logfiles
install -m 0755 -d %{buildroot}%{_sysconfdir}/log.d/conf/services
install -m 0755 -d %{buildroot}%{_sysconfdir}/log.d/scripts/services
install -m 0755 -d %{buildroot}%{_sysconfdir}/log.d/scripts/shared
install -m 0755 -d %{buildroot}%{_sysconfdir}/log.d/lib

install -m 0755 scripts/logwatch.pl %{buildroot}%{_sysconfdir}/log.d/scripts/logwatch.pl
for i in scripts/logfiles/* ; do
   if [ $(ls $i | wc -l) -ne 0 ] ; then
      install -m 0755 -d %{buildroot}%{_sysconfdir}/log.d/$i
      install -m 0755 $i/* %{buildroot}%{_sysconfdir}/log.d/$i
   fi
done
install -m 0755 scripts/services/* %{buildroot}%{_sysconfdir}/log.d/scripts/services
install -m 0755 scripts/shared/* %{buildroot}%{_sysconfdir}/log.d/scripts/shared
install -m 0755 lib/* %{buildroot}%{_sysconfdir}/log.d/lib

install -m 0644 conf/logwatch.conf %{buildroot}%{_sysconfdir}/log.d/conf/logwatch.conf
install -m 0644 conf/logfiles/* %{buildroot}%{_sysconfdir}/log.d/conf/logfiles
install -m 0644 conf/services/* %{buildroot}%{_sysconfdir}/log.d/conf/services

install -m 0755 -d %{buildroot}%{_mandir}/man8
install -m 0644 logwatch.8 %{buildroot}%{_mandir}/man8

rm -f %{buildroot}%{_sysconfdir}/log.d/logwatch \
   %{buildroot}%{_sysconfdir}/log.d/logwatch.conf \
   %{buildroot}%{_sysconfdir}/cron.daily/logwatch \
   %{buildroot}%{_sbindir}/logwatch

ln -s scripts/logwatch.pl %{buildroot}%{_sysconfdir}/log.d/logwatch
ln -s conf/logwatch.conf %{buildroot}%{_sysconfdir}/log.d/logwatch.conf
install -m 0755 -d %{buildroot}%{_sysconfdir}/cron.daily
ln -s ../log.d/scripts/logwatch.pl %{buildroot}%{_sysconfdir}/cron.daily/0logwatch
install -m 0755 -d %{buildroot}%{_sbindir}
ln -s ../..%{_sysconfdir}/log.d/scripts/logwatch.pl %{buildroot}%{_sbindir}/logwatch
