#!/bin/sh -e


case "$1" in
    configure|upgrade)
	conf=masterkey-gui-default.conf
	ln -sf /etc/masterkey/$conf /usr/share/masterkey-gui-default/config.masterkey
        WEBSERVERS="apache apache-ssl apache2"
	# masterkey-gui-default-apache-alias.conf is gone
	# masterkey-gui-default-apache-virtual.conf is not symlinked
	for apache in $WEBSERVERS; do
	    for conf in masterkey-gui-default-apache-directory.conf ; do
	      if [ -d "/etc/$apache/conf.d" ] && \
		  [ -x "/etc/init.d/$apache" ] && \
		  [ ! -e "/etc/$apache/conf.d/$conf" ]
		  then
		  echo "Installing masterkey-gui-default $conf file for $apache.."
		  ln -sf /etc/masterkey/$conf /etc/$apache/conf.d/$conf
		  if [ -f "/var/run/$apache.pid" ]; then
		      invoke-rc.d $apache reload
		  fi
	      fi
	    done
	done
	;;
    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

