#!/bin/sh

set -e

# These are included manually, as the postinst needs custom ordering.
dpkg-maintscript-helper mv_conffile /etc/default/ntp /etc/default/ntpsec 1.1.0\+dfsg1-2\~ ntpsec -- "$@"
dpkg-maintscript-helper mv_conffile /etc/init.d/ntp /etc/init.d/ntpsec 1.1.0\+dfsg1-2\~ ntpsec -- "$@"
dpkg-maintscript-helper mv_conffile /etc/ntp.conf /etc/ntpsec/ntp.conf 1.1.0\+dfsg1-2\~ ntpsec -- "$@"

installinit_error() {
	status=$?
	start-stop-daemon --stop --quiet --oknodo --pidfile /run/ntpd.pid && exit 0
	exit $status
}

# Automatically added by dh_installsystemd/13.11.4
if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
	deb-systemd-invoke stop 'ntpsec-rotate-stats.timer' 'ntpsec-systemd-netif.path' 'ntpsec.service' >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installinit/13.11.4
if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = remove ] && [ -x "/etc/init.d/ntpsec" ] ; then
	invoke-rc.d --skip-systemd-native ntpsec stop || installinit_error
fi
# End automatically added section

