#!/bin/sh
# This script is executed as part of the hotplug event with
# HOTPLUG_TYPE=iface, triggered by various scripts when an interface
# is configured (ACTION=ifup) or deconfigured (ACTION=ifdown).  The
# interface is available as INTERFACE, the real device as DEVICE.

[ -n "$VNET_BOOTING" ] && exit 0

[ "$DEVICE" == "lo" ] && exit 0

. /usr/lib/dpi.sh

case "$ACTION" in
        add)
        ;;
        delete)
        ;;
        commit)
                if [ -n "$ZACTION" ]; then
                        for zact in $ZACTION
                        do
                                zone=${zact%%=*}
                                op=${zact##*=}
                                option=0
                                for act in ${op//,/ }
                                do
                                        [ "$act" == "delete" ] && option=$(($option - 1))
                                        [ "$act" == "add" ] && option=$(($option + 1))
                                done
                                [ "$option" == "-1" ] && {
                                    dpi_del_restriction_zone $zone
                                }
                        done
                else
                        #do nothing
                        return 0
                fi
        ;;
        *)
                # (notify) do nothing
        ;;
esac
