#!/bin/sh -e
#
# debian/postrm for getpath
# If we're removing, kill any of our getpath calls.
#

umask 022
pkg=getpath

rmconf()
{
	#
	# Remove the conf file (only call on purge).
	# Also remove the debconf database entries.
	#

	rm -f /etc/getpath.conf

	if [ -e /usr/share/debconf/confmodule ]; then
		. /usr/share/debconf/confmodule
		db_purge
	fi

}

rmrc()
{
	#
	# Remove lines we know we auto-added to shell rc files.
	#

	if [ -e /etc/profile -a "`grep \"# auto added by getpath\" /etc/profile`" != "" ]; then
		cp /etc/profile /etc/profile.tmp
		grep -v "# auto added by getpath" /etc/profile.tmp > /etc/profile
		rm -f /etc/profile.tmp
	fi
	if [ -e /etc/csh.cshrc -a "`grep \"# auto added by getpath\" /etc/csh.cshrc`" != "" ]; then
		cp /etc/csh.cshrc /etc/csh.cshrc.tmp
		grep -v "# auto added by getpath" /etc/csh.cshrc.tmp > /etc/csh.cshrc
		rm -f /etc/csh.cshrc.tmp
	fi

}

case "$1" in
	(purge)
		rmconf
		rmrc
		;;
	(remove)
		rmrc
		;;
esac
exit 0
