#!/bin/bash

# This script is intended to be run from /etc/ifplugd/ifplugd.action
# or /etc/net/scripts/ifplugd.action. The only thing we should do is
# to finish configuration of a ready pre-created interface.

usage()
{
	echo "Usage: $0 <interface>" >&2
	exit 1
}

[ -z "$1" ] && usage
export NAME=$1

# forget everything we have inherited from ifplugd
export SCRIPTDIR=/etc/net/scripts
. $SCRIPTDIR/functions
pickup_defaults
. $SCRIPTDIR/functions-eth
init_nethost
if [ -d $IFACEDIR/$NAME@$NETHOST ]; then
	MYIFACEDIR=$IFACEDIR/$NAME@$NETHOST
else
	MYIFACEDIR=$IFACEDIR/$NAME
fi
export MYIFACEDIR NETPROFILE

init_netprofile
pickup_options

is_yes "$DISABLED" && {
	print_message "skipped disabled iface $NAME"
  exit 1
}

seen_iface $NAME && exit 0
add_seen_iface $NAME
export SEEN_IFACES
IN_IFPLUGD=yes $SCRIPTDIR/ifup-common $NAME
