#!/bin/sh

set -e

# Automatically added by dh_installinit/13.11.4
if [ "$1" = "remove" ] && [ -x "/etc/init.d/nfs-common" ] ; then
	chmod -x "/etc/init.d/nfs-common" >/dev/null || true
fi
if [ -z "${DPKG_ROOT:-}" ] && [ "$1" = "purge" ] ; then
	update-rc.d nfs-common remove >/dev/null
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = remove ] && [ -d /run/systemd/system ] ; then
	systemctl --system daemon-reload >/dev/null || true
fi
# End automatically added section
# Automatically added by dh_installsystemd/13.11.4
if [ "$1" = "purge" ]; then
	if [ -x "/usr/bin/deb-systemd-helper" ]; then
		deb-systemd-helper purge 'nfs-client.target' >/dev/null || true
	fi
fi
# End automatically added section


case "$1" in
    purge)
	for FILE in /etc/default/nfs-common /etc/idmapd.conf /etc/nfs.conf; do
	    # Taken from the ucf example postrm
	    for ext in '~' '%' .bak .dpkg-tmp .dpkg-new .dpkg-old .dpkg-dist;  do
		rm -f $FILE$ext
	    done
	    rm -f $FILE
	    if [ -x /usr/bin/ucf ]; then
		ucf --purge $FILE
	    fi
	done
	rm -f /etc/nfs.conf.d/local.conf

	rm -f /var/lib/nfs/state    \
	      /var/lib/nfs/sm/*     \
	      /var/lib/nfs/sm.bak/*
	    
	dpkg-statoverride --remove /sbin/mount.nfs || true
	;;
esac
