#!/bin/sh -e


case "$1" in
    configure|upgrade)
        WEBSERVERS="apache apache-ssl apache2"
	for apache in $WEBSERVERS; do
	    reload=""
	    for conf in masterkey-core-apache-alias.conf; do
		if [ -d "/etc/$apache/conf.d" ] && \
		    [ -x "/etc/init.d/$apache" ]
		    then
		    if [ ! -e "/etc/$apache/conf.d/$conf" ]
			then
			echo "Installing masterkey-core alias configuration file for $apache.."
			ln -sf /etc/masterkey/$conf /etc/$apache/conf.d/$conf
			reload=yes
		    fi
		    if [ -e /etc/$apache/mods-available/actions.load ] && \
			[ ! -e /etc/$apache/mods-enabled/actions.load ]
			then
			echo "Enabling module actions for $apache.."
			ln -s /etc/$apache/mods-available/actions.load /etc/$apache/mods-enabled/actions.load
			reload=yes
		    fi
		fi
	    done
	    if [ "$reload" -a -f "/var/run/$apache.pid" ]; then
		invoke-rc.d $apache reload
	    fi
	done
	if [ -d /usr/share/php ]; then
	    ln -sf /usr/share/masterkey-core/php/masterkey_bootstrap.php /usr/share/php/masterkey_bootstrap.php
	fi
        ;;
    
    abort-upgrade|abort-remove|abort-deconfigure)
        ;;
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac


# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0

