#! /bin/sh

set -e

case "$1" in
        remove)
               ;;
        purge)
               update-rc.d -f freeradius remove >/dev/null

               # Remove dangling links from sites-enabled.
               for link in /etc/freeradius/sites-enabled/*; do
                 if [ -L "$link" ] && [ ! -e "$link" ]; then
                   rm -f "$link"
                 fi
               done

	       if [ -L /etc/freeradius/certs/server.pem ]; then
	         rm -f /etc/freeradius/certs/server.pem
	       fi
	       if [ -L /etc/freeradius/certs/server.key ]; then
	         rm -f /etc/freeradius/certs/server.key
	       fi
	       if [ -L /etc/freeradius/certs/ca.pem ]; then
	         rm -f /etc/freeradius/certs/ca.pem
	       fi
	       if [ -L /etc/freeradius/certs/random ]; then
	         rm -f /etc/freeradius/certs/random
	       fi
	       rm -f /etc/freeradius/certs/dh

               rm -f /var/log/freeradius/radius.log* /var/log/freeradius/radwtmp*
               ;;
esac

#DEBHELPER#

exit 0
