#!/bin/sh

set -e

if [ "$1" = configure ]; then
  # Automatically added by dh_installinit
  (cd /usr/share/statsd && /usr/bin/npm install --production)

  if ! getent passwd _statsd > /dev/null; then
    adduser --system --quiet --home /nonexistent --no-create-home \
      --shell /bin/false --force-badname --group --gecos "StatsD User" _statsd
  fi

  if ! dpkg-statoverride --list /var/run/statsd >/dev/null 2>&1; then
    dpkg-statoverride --update --add _statsd _statsd 0755 /var/run/statsd
  fi

fi
