%endif
%post
+/sbin/ldconfig
%if 0%{?_with_systemd}
systemd-tmpfiles --create %{_tmpfilesdir}/%{name}.conf
%if 0%{?suse_version}
%else
/sbin/chkconfig --add ceph
%endif
-/sbin/ldconfig
%preun
%if 0%{?_with_systemd}
#################################################################################
%files radosgw
%defattr(-,root,root,-)
-%{_initrddir}/ceph-radosgw
%{_bindir}/radosgw
%{_bindir}/radosgw-admin
%{_mandir}/man8/radosgw.8*
%{_mandir}/man8/radosgw-admin.8*
-%{_sbindir}/rcceph-radosgw
%config(noreplace) %{_sysconfdir}/logrotate.d/radosgw
%config %{_sysconfdir}/bash_completion.d/radosgw-admin
%dir %{_localstatedir}/log/radosgw/
%dir %{_localstatedir}/lib/ceph/radosgw
+%if 0%{?_with_systemd}
+ %{_tmpfilesdir}/%{name}-radosgw.conf
+ %dir %{_tmpfilesdir}/
+ %{_unitdir}/ceph-radosgw@.service
+ %dir /usr/lib/ceph-radosgw
+ /usr/lib/ceph-radosgw/ceph-radosgw-prestart.sh
+%else
+ %{_initrddir}/ceph-radosgw
+ %{_sbindir}/rcceph-radosgw
+%endif
+
%post radosgw
/sbin/ldconfig
-%if %{defined suse_version}
-%fillup_and_insserv -f -y ceph-radosgw
+%if 0%{?suse_version}
+ # TODO: find out what exactly this systemd-tmpfiles inovcation is for
+ systemd-tmpfiles --create %{_tmpfilesdir}/ceph-radosgw.conf
+ # explicit systemctl daemon-reload (that's the only relevant bit of
+ # service_add_post; the rest is all sysvinit --> systemd migration which
+ # isn't applicable in this context (see above comment).
+ /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+%else
+ %if 0%{?suse_version}
+ %fillup_and_insserv -f -y ceph-radosgw
+ %endif
%endif
%preun radosgw
-%if %{defined suse_version}
-%stop_on_removal ceph-radosgw
+%if 0%{?_with_systemd}
+ SERVICE_LIST=$(systemctl | grep -E '^ceph-radosgw@' | cut -d' ' -f1)
+ if [ -n "$SERVICE_LIST" ]; then
+ for SERVICE in $SERVICE_LIST; do
+ /usr/bin/systemctl --no-reload disable $SERVICE > /dev/null 2>&1 || :
+ /usr/bin/systemctl stop $SERVICE > /dev/null 2>&1 || :
+ done
+ fi
+%else
+ %if 0%{?suse_version}
+ %stop_on_removal ceph-radosgw
+ %endif
%endif
%postun radosgw
/sbin/ldconfig
-%if %{defined suse_version}
-%restart_on_update ceph-radosgw
-%insserv_cleanup
+%if 0%{?_with_systemd}
+ SERVICE_LIST=$(systemctl | grep -E '^ceph-radosgw@' | cut -d' ' -f1)
+ if [ -n "$SERVICE_LIST" ]; then
+ for SERVICE in $SERVICE_LIST; do
+ /usr/bin/systemctl --no-reload disable $SERVICE > /dev/null 2>&1 || :
+ /usr/bin/systemctl try-restart $SERVICE > /dev/null 2>&1 || :
+ done
+ fi
+%else
+ %if 0%{?suse_version}
+ %restart_on_update ceph-radosgw
+ %insserv_cleanup
+ %endif
%endif
# Package removal cleanup
-if [ "$1" -eq "0" ] ; then
- rm -rf /var/log/radosgw
+if [ "$1" = "0" ] ; then
+ rm -rf /var/log/radosgw
fi