#!/bin/sh

set -e

case "${1}" in
	configure)
		. /usr/share/debconf/confmodule

		db_get icingaweb2-module-director/enable
		MODULE_ENABLE="${RET:-true}"

		db_stop

		if [ "${MODULE_ENABLE}" = "true" ]
		then
			# Leave local overrides in place, if any
			if [ -f /etc/tmpfiles.d/icingaweb2-module-director.conf ] && [ ! -s /etc/tmpfiles.d/icingaweb2-module-director.conf ]
			then
				rm -f /etc/tmpfiles.d/icingaweb2-module-director.conf
			fi
		else
			# Mask tmpfiles.d so that the module is not enabled
			touch /etc/tmpfiles.d/icingaweb2-module-director.conf
		fi
		;;

	abort-upgrade|abort-remove|abort-deconfigure)

		;;

	*)
		echo "postinst called with unknown argument: \`${1}'." >&2
		exit 1
		;;
esac

#DEBHELPER#

exit 0
