#!/bin/sh
# postinst script for yandex-statinfra-api
#
# see: dh_installdeb(1)


set -e

case "$1" in
    configure)
        LOGDIR="/var/log/yandex-statinfra-api"
        mkdir -p "$LOGDIR"
        chown -R syslog:statbox "$LOGDIR"
        chmod -R u=rwX,g=rwX,o=rX "$LOGDIR"
        chmod g+s "$LOGDIR"

        RUNDIR="/var/run/statbox"
        mkdir -p "$RUNDIR"
        chown statbox:statbox "$RUNDIR"
        chmod 755 "$RUNDIR"

        for service_name in statinfra-api-celery statinfra-api-celerybeat
        do
            initctl stop ${service_name} || true
            initctl start ${service_name}
        done
    ;;

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

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac


# Place for autogenerated code:

#DEBHELPER#

exit 0
