#!/bin/sh -e
# postinst script for linkchecker-web
#
# see: dh_installdeb(1)

case "$1" in
configure|reconfigure|abort-upgrade|abort-remove|abort-deconfigure)
    ;;
*)
    echo "postinst called with unknown argument \`$1'" >&2
    exit 1
    ;;
esac

#DEBHELPER#

if [ "$1" = "configure" ]; then

  CONF=linkchecker

  if [ -e /usr/share/apache2/apache2-maintscript-helper ]; then
    # apache 2.4
    . /usr/share/apache2/apache2-maintscript-helper
    apache2_invoke enconf $CONF
  elif dpkg-query -f '${Version}' -W 'apache2.2-common' >/dev/null 2>&1; then
    # apache 2.2
    # the web interface uses content negotiation
    a2enmod -q negotiation
    [ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/$CONF.conf ] && ln -s ../conf-available/$CONF.conf /etc/apache2/conf.d/$CONF.conf
  fi

  # reload apache configuration
  if [ -x /etc/init.d/apache2 ]; then
    invoke-rc.d apache2 reload || true
  fi
fi

exit 0
