#!/bin/sh

set -e

# creating candid group if he isn't already there
if ! getent group candid >/dev/null; then
    # Adding system group: candid.
    addgroup --system candid >/dev/null
fi

# creating candid user if he isn't already there
if ! getent passwd candid >/dev/null; then
    # Adding system user: candid.
    adduser \
      --system \
          --disabled-login \
      --ingroup candid \
      --gecos "Canonical Identity server" \
      --shell /bin/false \
      --no-create-home --home /nonexistent \
      candid  >/dev/null
fi

# create log dir
mkdir -p /var/log/identity
chown candid:candid /var/log/identity

#DEBHELPER#

exit 0
