#!/bin/sh -e

update-alternatives --install /sbin/ifenslave ifenslave /sbin/ifenslave-2.6 260 \
        --slave /usr/share/man/man8/ifenslave.8.gz ifenslave.8.gz /usr/share/man/man8/ifenslave-2.6.8.gz

mv_conffile() {
        local OLDCONFFILE="$1"
        local NEWCONFFILE="$2"

        [ -e "$OLDCONFFILE" ] || return 0

        echo "Preserving user changes to $NEWCONFFILE ..."
        mv -f "$NEWCONFFILE" "$NEWCONFFILE".dpkg-new
        mv -f "$OLDCONFFILE" "$NEWCONFFILE"
}

case "$1" in
configure)
        if [ -n "$2" ] && dpkg --compare-versions "$2" le "1.1.0-6"; then
                mv_conffile "/etc/network/if-up.d/ifenslave" "/etc/network/if-pre-up.d/ifenslave"
                mv_conffile "/etc/network/if-down.d/ifenslave" "/etc/network/if-post-down.d/ifenslave"
        fi
esac


