#! /bin/sh
# post removal script for the Debian GNU/Linux sendfile package

set -e

if [ "$1" = "remove" ]
then
    for profile in /etc/profile /etc/csh.login
    do
	grep -v 'check-sendfile' $profile > $profile.new || /bin/true
	mv -f $profile.new $profile
    done
fi

if [ "$1" = "purge" ]
then
  rm -rf /var/log/sendfile >/dev/null

    if [ -d /var/spool/sendfile ]
    then
	cd /var/spool/sendfile

	if [ -n "`ls`" ]; then
	    for u in *; do
		for num in 7 6 5 4 3 2 1; do
		    if [ -f $u/log.$num ]; then rm -f $u/log.$num; fi
		done
	    done
	fi
	cd /
	rm -rf /var/spool/sendfile >/dev/null
    fi
fi

test ! -x /usr/sbin/update-inetd || /usr/sbin/update-inetd --remove saft
