-# Plug the shibboleth SP into Apache2 on a Red Hat system.
-[ -d %{_sysconfdir}/httpd/conf.d ] || exit 0
-[ -f %{_sysconfdir}/httpd/conf.d/shib.conf ] && exit 0
-cp -p %{_sysconfdir}/shibboleth/apache2.config \
- %{_sysconfdir}/httpd/conf.d/shib.conf
+# Plug the SP into Apache on a recognized system.
+APACHE_CONFIG="no"
+if [ -f $RPM_BUILD_ROOT/%{_libdir}/%{name}/mod_shib_13.so ] ; then
+ APACHE_CONFIG="apache.config"
+fi
+if [ -f $RPM_BUILD_ROOT/%{_libdir}/%{name}/mod_shib_20.so ] ; then
+ APACHE_CONFIG="apache2.config"
+fi
+if [ -f $RPM_BUILD_ROOT/%{_libdir}/%{name}/mod_shib_22.so ] ; then
+ APACHE_CONFIG="apache22.config"
+fi
+if [ "$APACHE_CONFIG" != "no" ] ; then
+ APACHE_CONFD="no"
+ if [ -d %{_sysconfdir}/httpd/conf.d ] ; then
+ APACHE_CONFD="%{_sysconfdir}/httpd/conf.d"
+ fi
+ if [ -d %{_sysconfdir}/apache2/conf.d ] ; then
+ APACHE_CONFD="%{_sysconfdir}/apache2/conf.d"
+ fi
+ if [ "$APACHE_CONFD" != "no" ] ; then
+ if [ ! -f $APACHE_CONFD/shib.conf ] ; then
+%if "%{_vendor}" == "suse"
+ %{__sed} "s/\/usr\/doc\/%{name}/\/usr\/share\/doc\/packages\/%{name}/g" \
+ %{_sysconfdir}/%{name}/$APACHE_CONFIG \
+ > $APACHE_CONFD/shib.conf
+%else
+ %{__sed} "s/\/usr\/doc\/%{name}/\/usr\/share\/doc\/%{name}-@-VERSION-@/g" \
+ %{_sysconfdir}/%{name}/$APACHE_CONFIG \
+ > $APACHE_CONFD/shib.conf
+%endif
+ fi
+ fi
+fi
+
+# Install the shibd init.d scripts and service
+%if "%{_vendor}" == "redhat"
+ if [ -d %{_sysconfdir}/init.d ] ; then
+ if [ ! -f %{_sysconfdir}/init.d/shibd ] ; then
+ %{__cp} -p %{_sysconfdir}/%{name}/shibd-%{_vendor} %{_sysconfdir}/init.d/shibd
+ %{__chmod} 755 %{_sysconfdir}/init.d/shibd
+ chkconfig --add shibd
+ fi
+ fi
+%endif
+
+# Key generation
+cd %{_sysconfdir}/%{name}
+sh ./keygen.sh -b