#! /bin/sh

set -e

case "$1" in
  remove)
        if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
		invoke-rc.d freeradius stop
	else
		/etc/init.d/freeradius stop
	fi

        for file in /etc/freeradius/mods-config/files/pre-proxy \
          /etc/freeradius/mods-config/preprocess/huntgroups \
          /etc/freeradius/mods-config/preprocess/hints \
          /etc/freeradius/mods-config/files/accounting \
          /etc/freeradius/experimental.conf \
          /etc/freeradius/proxy.conf \
          /etc/freeradius/clients.conf
        do
          if dpkg-statoverride --list | grep -qw $file$; then
            dpkg-statoverride --remove $file
          fi
        done

        for dir in /etc/freeradius/certs \
          /etc/freeradius/sites-available \
          /etc/freeradius/sites-enabled \
          /etc/freeradius/mods-available \
          /etc/freeradius/mods-enabled \
          /etc/freeradius/mods-config/attr_filter \
          /etc/freeradius/mods-config \
          /etc/freeradius/policy.d \
          /var/run/freeradius \
          /var/log/freeradius
        do
          if dpkg-statoverride --list | grep -qw $dir$; then
            dpkg-statoverride --remove $dir
          fi
        done
	;;
esac

#DEBHELPER#

exit 0
