#! /bin/sh

set -e

case "$1" in
	remove)
		;;

	purge)
		if dpkg-statoverride --list | grep -qw /var/cache/netdata; then
			dpkg-statoverride --remove /var/cache/netdata
		fi

		if dpkg-statoverride --list | grep -qw /var/lib/netdata/www; then
			dpkg-statoverride --remove /var/lib/netdata/www
		fi

		if dpkg-statoverride --list | grep -qw /var/lib/netdata; then
			dpkg-statoverride --remove /var/lib/netdata
		fi

		if getent passwd netdata >/dev/null; then
			if [ -x /usr/sbin/deluser ]; then
				deluser --quiet --system netdata || echo "Unable to remove netdata user"
			fi
		fi

		if getent group netdata >/dev/null; then
			if [ -x /usr/sbin/delgroup ]; then
				delgroup --quiet --system netdata || echo "Unable to remove netdata group"
			fi
		fi

		;;

	*)
		;;
esac

#DEBHELPER#

exit 0

