#!/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
}

unset IFACEDIR MYIFACEDIR SCRIPTDIR NAME NETPROFILE NETHOST SEEN_IFACES
[ -z "$1" ] && usage
NAME=$1

. ${SCRIPTDIR:=/etc/net/scripts}/functions
init_nethost
if [ -d $IFACEDIR/$NAME@$NETHOST ]; then
	MYIFACEDIR=$IFACEDIR/$NAME@$NETHOST
else
	MYIFACEDIR=$IFACEDIR/$NAME
fi
export IFACEDIR MYIFACEDIR SCRIPTDIR NAME NETPROFILE SEEN_IFACES

init_netprofile
pickup_options

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

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