#!/bin/sh

set -e

case "$1" in
    install|upgrade)
    	# if the /etc/dhclient.conf from dhcp-client was modified, 
	# bring it forward to /etc/dhcp3/dhclient.conf, but in a way not
	# to upset dpkg about a changed conffile
        if [ ! -e /etc/dhcp3/dhclient.conf ] && [ -e /etc/dhclient.conf ] && \
	    ! >/dev/null 2>&1 md5sum -c - <<-EOF; then
		10830c7543724cfd36f10dd87a5f98eb  /etc/dhclient.conf
		EOF
		mkdir -p /etc/dhcp3
		cp /etc/dhclient.conf /etc/dhcp3/dhclient.conf.oldconfig
        fi

	# We renamed debug-enter to debug - handle the transition
	if [ ! -e /etc/dhcp3/dhclient-enter-hooks.d/debug ] && \
	      [ -e /etc/dhcp3/dhclient-enter-hooks.d/debug-enter ]; then
		mv /etc/dhcp3/dhclient-enter-hooks.d/debug-enter \
		   /etc/dhcp3/dhclient-enter-hooks.d/debug
	else
	    rm -f /etc/dhcp3/dhclient-enter-hooks.d/debug-enter
	fi

	# We renamed debug-exit to debug - handle the transition
	if [ ! -e /etc/dhcp3/dhclient-exit-hooks.d/debug ] && \
	      [ -e /etc/dhcp3/dhclient-exit-hooks.d/debug-exit ]; then
		mv /etc/dhcp3/dhclient-exit-hooks.d/debug-exit \
		   /etc/dhcp3/dhclient-exit-hooks.d/debug
	else
	    rm -f /etc/dhcp3/dhclient-exit-hooks.d/debug-exit
	fi

	# We moved /etc/dhcp3/dhclient-script to /sbin in 3.0.4-2
	if dpkg --compare-versions "$2" lt-nl "3.0.4-2"; then
		if [ -e /etc/dhcp3/dhclient-script ]; then
			if >/dev/null 2>&1 md5sum -c - <<-EOF; then
			2b18b5c59b26d00aa115716b3da2ed26  /etc/dhcp3/dhclient-script
			EOF
				rm -f /etc/dhcp3/dhclient-script
			fi
		fi
	fi
        ;;

    abort-upgrade)
        ;;

    *)
        echo "preinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

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



exit 0


