#!/bin/sh

set -e

GROUP="eviacam"

. /usr/share/debconf/confmodule

#DEBHELPER#

case "$1" in
	configure)
		db_get eviacamloader/eviacamloader_setuid
		if [ "$RET" = true ]; then
			
			# Create group when necessary
			if ! getent group "$GROUP" >/dev/null; then
				addgroup --system "$GROUP"
			fi
			
			#if ! dpkg-statoverride --list /usr/bin/eviacamloader >/dev/null 2>&1; then
			#	dpkg-statoverride --update --add root "$GROUP" 4750 /usr/bin/eviacamloader
			#fi
			chown root:$GROUP /usr/bin/eviacamloader
			chmod 4750 /usr/bin/eviacamloader
		else
			#if dpkg-statoverride --list /usr/bin/eviacamloader >/dev/null 2>&1; then
			#	dpkg-statoverride --update --remove /usr/bin/eviacamloader
			#fi
			chown root:root /usr/bin/eviacamloader
			chmod 0755 /usr/bin/eviacamloader
		fi
		;;
	abort-upgrade|abort-remove|abort-deconfigure)
		;;
	*)
		echo "postinst called with unknown argument \`$1'" >&2
		;;
esac

