anchor.diff:  export PATH=/opt/puppet/bin:$PATH
   <% end -%>
   %if 0%{?_with_systemd}
  -# Always reload the .service files if using systemd, in case they have changed.
  -/usr/bin/systemctl daemon-reload
  +%if 0%{?fedora} || 0%{?rhel}
  +%systemd_post %{name}.service
  +%else
  +%if 0%{?suse_version}
  +%service_add_post %{name}.service
  +%endif
  +%endif
   %else
   # If this is an install (as opposed to an upgrade)...
   if [ "$1" = "1" ]; then
  
positive.code: if [ -f "<%= @install_dir %>/start_service_after_upgrade" ] ; then
     rm <%= @install_dir %>/start_service_after_upgrade
  fi
  # If this is an upgrade (as opposed to an install) then we need to check
  #  and see if the service is running.  If it is, we need to stop it.
  #  we want to shut down and disable the service.
  if [ "$1" = "2" ] ; then
  %if 0%{?_with_systemd}
      # We test to see if the systemd service file exists because in upgrades from < 1.6.0,
      # puppetdb may still be using sysv and in that case we need to use the sysv tools.
      if [ -f %{_unitdir}/%{name}.service ]; then
        if /usr/bin/systemctl status %{name}.service > /dev/null; then
          # If we need to restart the service after the upgrade
          #  is finished, we will touch a temp file so that
          #  we can detect that state
          touch <%= @install_dir %>/start_service_after_upgrade
          /usr/bin/systemctl stop %{name}.service >/dev/null 2>&1
        fi
      elif [ -f %{_initddir}/%{name} ]; then
        if /sbin/service %{name} status > /dev/null ; then
          # If we need to restart the service after the upgrade
          #  is finished, we will touch a temp file so that
          #  we can detect that state
          touch <%= @install_dir %>/start_service_after_upgrade
          /sbin/service %{name} stop >/dev/null 2>&1
        fi
      fi
  %else
      if /sbin/service %{name} status > /dev/null ; then
          # If we need to restart the service after the upgrade
          #  is finished, we will touch a temp file so that
          #  we can detect that state
          touch <%= @install_dir %>/start_service_after_upgrade
          /sbin/service %{name} stop >/dev/null 2>&1
      fi
  %endif
  fi
  # Add PuppetDB user
  getent group %{name} > /dev/null || groupadd -r %{name}
  getent passwd %{name} > /dev/null || \
  
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
  