#!/bin/sh
# preinst script 
#
# see: dh_installdeb(1)

set -e

case "$1" in
	install|upgrade)
		# Create group and user monitor if does not exist
		if ! getent group monitor >/dev/null; then
			groupadd -g 1090 monitor
		else
			echo "monitor group already exists"
		fi

		if ! getent passwd monitor >/dev/null; then
			useradd --uid 1090 --gid 1090 --create-home --home-dir /home/monitor monitor
		else
			echo "monitor user already exists"
		fi
                if lsb_release -cs | grep -q xenial
                then
                    gpasswd -a monitor systemd-journal
                fi
	;;

	abort-upgrade)
	;;

	*)
		echo "preinst called with unknown argument \`$1'" >&2
		exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

