#!/bin/sh

/opt/puppetlabs/server/apps/puppetdb/scripts/install.sh postinst_deb

# On upgrade, we should restart the service if it's running
if [ $1 = 'configure' -a -n $2 ] ; then
  if [ -e "/lib/systemd/system/puppetdb.service" ] ; then
    # Using systemd
    if [ -e '/etc/init.d/puppetdb' ] ; then
      # We need to clean up the old sysv files if they still exist
      rm '/etc/init.d/puppetdb'
    fi
    systemctl daemon-reload >/dev/null 2>&1 || :
    systemctl try-restart puppetdb.service ||:
  else
    # Using sysv
    invoke-rc.d puppetdb try-restart || :
  fi
fi
