#!/bin/sh -e

# Only shut the daemon down if we're really removing the package.  If this is
# an upgrade, we will instead do a restart in the postinst... this keeps ntopng
# from being left shut down for a long time, which could pose problems.
case "$1" in
	upgrade)
	;;

	*)
	echo "Stopping ntopng services..."
	if grep -q systemd /proc/1/comm; then
		systemctl stop ntopng

		systemctl disable ntopng

		systemctl daemon-reload
		systemctl reset-failed
	else
		/etc/init.d/ntopng stop
		update-rc.d ntopng remove >/dev/null
	fi
	;;
esac

exit 0
