#!/bin/sh
# postinst script for riak
#
# see: dh_installdeb(1)

set -e

# install startup script
update-rc.d riak defaults >/dev/null

# create riak group
if ! getent group riak >/dev/null; then
        addgroup --system riak 
fi

# create raiak user
if ! getent passwd riak >/dev/null; then
        adduser --ingroup riak --home /var/lib/riak --disabled-password \
		--system --shell /bin/bash --no-create-home \
		--gecos "Riak Data Store" riak
fi

chown -R riak:riak /var/lib/riak
chown -R riak:riak /var/run/riak
chown -R riak:riak /var/log/riak
chmod 0755 /var/run/riak /etc/riak 


case "$1" in
    configure)
    ;;

    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

