#!/bin/sh
# postinst script for ebtables
#
# see: dh_installdeb(1)

set -e

if [ "$1" = "configure" ]; then
    if dpkg --compare-versions "$2" le-nl "2.0.10.4-3.2~"; then
	if [ -d /var/lib/ebtables ]; then
	    rmdir --ignore-fail-on-non-empty /var/lib/ebtables
	fi
    fi
    if dpkg --compare-versions "$2" le "2.0.10.4+snapshot20181205-2"; then
	update-rc.d ebtables remove
	deb-systemd-helper disable ebtables.service
	deb-systemd-helper purge ebtables.service
    fi
    # Clean-up the old compat symlinks for /sbin -> /usr/sbin
    LIST="ebtables ebtables-save ebtables-restore"
    for i in $LIST; do
	if [ -e "/sbin/$i" ] && [ $(readlink /sbin/$i) = /usr/sbin/$i ] ; then
	    rm /sbin/$i
	fi
    done
fi

# Providing alternatives with lower priority than those provided by iptables >= 1.8

if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ]; then
    update-alternatives \
	--install /usr/sbin/ebtables ebtables /usr/sbin/ebtables-legacy 10 \
	--slave /usr/sbin/ebtables-restore ebtables-restore /usr/sbin/ebtables-legacy-restore \
	--slave /usr/sbin/ebtables-save ebtables-save /usr/sbin/ebtables-legacy-save
fi

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

# Automatically added by dh_installdeb/13.6
dpkg-maintscript-helper rm_conffile /etc/init.d/ebtables 2.0.10.4\+snapshot20181205-2 -- "$@"
dpkg-maintscript-helper rm_conffile /etc/default/ebtables 2.0.10.4\+snapshot20181205-2 -- "$@"
# End automatically added section


exit 0
