#!/bin/sh
# postinst script for centrala

apache_install() {
	mkdir -p /etc/apache2/conf-available
	ln -sf ../../centrala/apache.conf /etc/apache2/conf-available/centrala.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 centrala
	elif [ "$COMMON_STATE" = "installed" ] || [ "$COMMON_STATE" = "unpacked" ] ; then
		[ -d /etc/apache2/conf.d/ ] && [ ! -L /etc/apache2/conf.d/centrala.conf ] && ln -s ../conf-available/centrala.conf /etc/apache2/conf.d/centrala.conf
	fi
}

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

exit 0
