anchor.diff:  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 || \
  
positive.code: 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
  %else
  # If this is an install (as opposed to an upgrade)...
  if [ "$1" = "1" ]; then
  
negative.code: %endif
  <% end -%>
  
  # Fedora 17 and later, EL > 7 and OpenSUSE >= 12.1 use systemd
  %if 0%{?fedora} >= 18 || 0%{?rhel} >= 7 || 0%{?suse_version} >= 1210
  %global _with_systemd 1
  %else
  %global _with_systemd 0
  