#!/bin/sh

set -e

if [ "$1" = configure ]; then
  # Versions of the dhcpcd5 package prior to 7.0.8-1 didn't remove this
  # alternative in postrm on upgrade. We don't provide this binary anymore, so
  # remove this alternative to avoid dangling symlinks.
  update-alternatives --remove dhcpcd /sbin/dhcpcd5

  # Move DUID and leases from the location used by previous versions of the
  # dhcpcd5 package, if necessary.
  olddir=/var/lib/dhcpcd5
  newdir=/var/lib/dhcpcd
  if [ -d $olddir ]; then
    if [ -n "$(ls -A $olddir)" ] && [ -z "$(ls -A $newdir)" ]; then
      cp -ar $olddir/. $newdir
    fi
    rm -rf $olddir
  fi
fi

#DEBHELPER#
