anchor.diff:  %preun
   # If this is an uninstall (as opposed to an upgrade) then
   #  we want to shut down and disable the service.
  +%if 0%{?_with_systemd}
  +%if 0%{?fedora} || 0%{?rhel}
  +%systemd_preun %{name}.service
  +%else
  +%if 0%{?suse_version}
  +%service_del_preun %{name}.service
  +%endif
  +%endif
  +%else
   if [ "$1" = "0" ] ; then
  -%if 0%{?_with_systemd}
  -    /usr/bin/systemctl stop %{name}.service
  -    /usr/bin/systemctl disable %{name}.service
  -%else
       /sbin/service %{name} stop >/dev/null 2>&1
       /sbin/chkconfig --del %{name}
  -%endif
   fi
  +%endif
   
   %postun
  +%if 0%{?_with_systemd}
  +%if 0%{?fedora} || 0%{?rhel}
  +%systemd_postun_with_restart %{name}.service
  +%else
  +%if 0%{?suse_version}
  +%service_del_postun %{name}.service
  +%endif
  +%endif
  +%else
   # Remove the rundir if this is an uninstall (as opposed to an upgrade)...
   if [ "$1" = "0" ]; then
       rm -rf %{_rundir}/%{name} || :
  -%if 0%{?_with_systemd}
  -    # Restart systemd after the service file is removed
  -    /usr/bin/systemctl daemon-reload
  +elif [ "$1" = "1" ] ; then
  +%if 0%{?fedora} || 0%{?rhel}
  +    /sbin/service %{name} condrestart >/dev/null 2>&1 || :
  +%else
  +%if 0%{?suse_version}
  +    /sbin/service %{name} try-restart >/dev/null 2>&1 || :
  +%endif
   %endif
   fi
  -
  -# If this is an upgrade (as opposed to an install) then we need to check
  -#  and see if we stopped the service during the install (we indicate
  -#  this via the existence of a temp file that was created during that
  -#  phase).  If we did, then we need to restart it.
  -if [ "$1" = "1" ] ; then
  -    if [ -f "<%= @install_dir %>/start_service_after_upgrade" ] ; then
  -        rm <%= @install_dir %>/start_service_after_upgrade
  -%if 0%{?_with_systemd}
  -        /usr/bin/systemctl start %{name}.service >/dev/null 2>&1
  -%else
  -        /sbin/service %{name} start >/dev/null 2>&1
  -%endif
  -    fi
  -fi
  +%endif
   
   
   %files
  
positive.code: %endif
  <% end -%>
  
  # Fedora 17 and later and EL > 7 use systemd
  %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7
  %global _with_systemd 1
  %else
  %global _with_systemd 0
  
negative.code: Requires:      procps
  %else
  BuildRequires: /usr/sbin/useradd
  %endif
  %if 0%{?_with_systemd} 
  %if 0%{?fedora} || 0%{?rhel}
  BuildRequires:    systemd
  Requires(post):   systemd
  Requires(preun):  systemd
  Requires(postun): systemd
  %else
  %if 0%{?suse_version}
  BuildRequires:    systemd
  %{?systemd_requires}
  %endif
  %endif
  %else
  %if 0%{?fedora} || 0%{?rhel}
  # Required for %%post and %%preun
  Requires:       chkconfig
  %endif
  