#!/bin/sh

# Note: Changes to this section may require synchronisation with the install.sh
# source based installation method.

if [ "$1" = install ] || [ "$1" = upgrade ]; then
    # Note: changes to this section of the spec may require synchronisation with the
    # install.sh source based installation methodology.
    #
    # Add puppetdb group
    getent group puppetdb > /dev/null || \
      groupadd -r puppetdb || :
    # Add puppetdb user
    if getent passwd puppetdb > /dev/null; then
      usermod --gid puppetdb \
        --home /opt/puppetlabs/server/data/puppetdb \
        --comment "puppetdb daemon" puppetdb || :
    else
      useradd -r --gid puppetdb \
        --home /opt/puppetlabs/server/data/puppetdb  --shell $(which nologin) \
        --comment "puppetdb daemon"  puppetdb || :
    fi


fi
