#! /bin/sh
# postrm script for caudium
#
# $Id: postrm,v 1.4.2.4 2005/10/31 15:39:45 grendel Exp $
#
# see: dh_installdeb(1)

set -e

# summary of how this script can be called:
#        * <postrm> `remove'
#        * <postrm> `purge'
#        * <old-postrm> `upgrade' <new-version>
#        * <new-postrm> `failed-upgrade' <old-version>
#        * <new-postrm> `abort-install'
#        * <new-postrm> `abort-install' <old-version>
#        * <new-postrm> `abort-upgrade' <old-version>
#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
# for details, see /usr/share/doc/packaging-manual/

BFILE=/var/backups/caudium.tar.gz

case "$1" in
       purge)
	if [ -L /var/www/index.html ]; then
	  IFILE="`readlink /var/www/index.html`"
	  if [ "$IFILE" = "../../usr/share/doc/caudium/www/index.html" ]; then
	    rm -f /var/www/index.html
	  fi
	fi
	
	rm -f /etc/default/caudium
	rm -rf /etc/caudium
	
	# Remove the links to the vera fonts
	for f in /usr/lib/caudium/fonts/ttf/*.ttf; do
	  if [ -L $f ]; then
	    rm -f $f
	  fi
	done
	
	if [ -d /usr/share/caudium ]; then
	  rm -r /usr/share/caudium
	fi
	
	rm -rf /usr/lib/caudium/caudium-images
	
	# Try to remove the dirs, if they're empty	
	if [ -d /usr/local/share/caudium ]; then
	  if [ -d /usr/local/share/caudium/modules ]; then
            rmdir /usr/local/share/caudium/modules || true
	  fi
	  rmdir /usr/local/share/caudium || true
	fi
	
	#
	# Clean the cache files
	#
	rm -rf /var/cache/caudium /var/state/caudium
	
	if [ -f /var/run/caudium/caudium.pid ]; then
	  rm /var/run/caudium/caudium.pid
	fi
	;;
	
       remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
        
        ;;

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

esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#


exit 0
