#!/bin/sh

if [ "$1" = install ] || [ "$1" = upgrade ]; then
    # Create the "puppetdb" user
    if ! getent passwd puppetdb  > /dev/null; then
        # Use -r here for redhat 5 compatiblity, instead of --system
        adduser -r --home /usr/share/puppetdb puppetdb
    fi

    # Create the "puppetdb" group, if it is missing, and set the
    # primary group of the "puppetdb" user to this group.
    if ! getent group puppetdb > /dev/null; then
        # Use -r here for redhat 5 compatiblity, instead of --system
        groupadd -r puppetdb
        usermod -g puppetdb puppetdb
    fi
fi
