#!/bin/sh
set -e

if [ "$1" = "configure" ] ; then
    if ! getent group intelmq >/dev/null 2>&1; then
        groupadd -r intelmq
    fi
    if ! getent passwd intelmq >/dev/null 2>&1; then
        useradd -r -d /var/lib/intelmq/ -c "user running intelmq" -g intelmq -s /bin/bash intelmq
    fi
    chmod -R g+w /var/lib/intelmq/*
    chown -R intelmq:intelmq /etc/intelmq/ /var/lib/intelmq/ /var/log/intelmq/
    systemd-tmpfiles --create /usr/lib/tmpfiles.d/intelmq.conf
fi

#DEBHELPER#
