#!/bin/sh

# postinst script for kafka
#
# see: dh_installdeb(1)

set -e

case "$1" in
    configure|reconfigure)
        if ! getent passwd kafka >/dev/null; then
            # Adding system user: kafka.
            adduser \
                --system \
                --group \
                --no-create-home \
                --home /nonexistent \
                --gecos "Apache Kafka" \
                --shell /bin/false \
                kafka >/dev/null 2>/dev/null || :
        fi

        # chown kafka directories
        chown kafka:kafka /var/log/kafka
        chown kafka:kafka /var/spool/kafka
    ;;

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

    *)
        echo "postinst 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
