#!/bin/sh

set -eu

USER="keydb"
GROUP="$USER"
CONFFILE="/etc/keydb/keydb.conf"

if [ "$1" = "configure" ]
then
	if ! dpkg-statoverride --list ${CONFFILE} >/dev/null 2>&1
	then
		dpkg-statoverride --update --add ${USER} ${GROUP} 640 ${CONFFILE}
	fi
fi

#DEBHELPER#

if [ "$1" = "configure" ]
then
	find /etc/keydb -maxdepth 1 -type d -name 'keydb-server.*.d' -empty -delete
fi

systemctl daemon-reload

exit 0
