#!/bin/sh -e
# postrm script for lighttpd

set -e

if [ "$1" = "purge" ]; then
    rm -rf /var/log/lighttpd /run/lighttpd /var/cache/lighttpd


    if [ -d /etc/lighttpd/conf-enabled/ ] ; then
        # The loop below fixes #642494 (mostly)
        for link in /etc/lighttpd/conf-enabled/*.conf ; do
            target=$(readlink "$link") || true
	    if [ -n "$target" ] && [ ! -e "/etc/lighttpd/conf-enabled/$target" ] ; then
                echo "removing dangling symlink $link ..."
                rm -f $link
            fi
        done
    fi
fi

#DEBHELPER#

exit 0
