#!/bin/sh
# postinst script for estetistic

apache_install() {
	mkdir -p /etc/apache2/conf-available
	ln -sf ../../estetistic/apache.conf /etc/apache2/conf-available/estetistic.conf
	
	COMMON_STATE=$(dpkg-query -f '${Status}' -W 'apache2.2-common' 2>/dev/null | awk '{print $3}' || true)

	if [ -e /usr/share/apache2/apache2-maintscript-helper ] ; then
		. /usr/share/apache2/apache2-maintscript-helper
		apache2_invoke enconf estetistic
	elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
		[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/estetistic.conf ] && ln -s ../conf-available/estetistic.conf /etc/apache2/conf.d/estetistic.conf
	fi
}

if [ "$1" = "configure" ]; then
	apache_install $@
fi

exit 0
