#! /bin/sh
# postrm script for GOsa
#

case "$1" in
    purge|remove)
	## PURGE!!!
	if [ "$1" = "purge" ] ; then
	    if [ -d /var/spool/gosa ] ; then
		echo "Removing /var/spool/gosa as requested."
		rm -Rf /var/spool/gosa
	    fi
	fi

        # Get apache versions running
        servers=""
        for srv in apache apache-ssl; do
                dpkg -s $srv | grep -q "^Status:.*not-installed"
                if [ $? -eq 1 ]; then
                        servers="$srv $servers"
                fi
        done

	# Adapt server configs
        for server in $servers ; do
		# remove GOsa include
		includefile=/etc/gosa/apache.conf

		case "$1" in
			purge)
				if [ -e /usr/share/wwwconfig-common/apache-uninclude_all.sh ] ; then
					. /usr/share/wwwconfig-common/apache-uninclude_all.sh
					if [ "$status" = "purge" ] ; then
						restart="$restart $server"
					fi
				else
					echo "Can not unconfigure gosa from apache because wwwconfig-common is removed."
				fi
			;;

			remove)
				if [ -e /usr/share/wwwconfig-common/apache-cominclude_all.sh ] ; then
					. /usr/share/wwwconfig-common/apache-cominclude_all.sh
					if [ "$status" = "comment" ] ; then
						restart="$restart $server"
					fi
				else
					echo "Can not unconfigure imp from apache because wwwconfig-common is removed."
				fi
			;;
		esac
	done
        
	# Restart servers
        /usr/share/wwwconfig-common/restart.sh

    ;;
    upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)

    ;;

    *)
        echo "postrm called with unknown argument \`$1'" >&2
        exit 0
    ;;
esac



exit 0
