#!/bin/bash


#Install the networking if it does not exist
/sbin/net-boot

#
# Build list of interfaces from boot.conf and possible network.conf for network interfaces
#
INTERFACES=()
if [ -e /etc/boot.conf ]; then 
	echo "Bringing up interfaces listed in /etc/boot.conf"
        . /etc/boot.conf
else
	echo "Board specific interfaces not found..."
	echo "Bringing up Guinnux interfaces listed in /etc/boot.conf.guinnux"
        . /etc/boot.conf.guinnux
fi
if [ -e /etc/network.conf ]; then
	echo "and network interfaces in /etc/network.conf..."
	. /etc/network.conf
else
	echo "no additional interfaces specified..."
fi


#
# Clear out ifstate, since we know all interfaces are
# down at boot time. Could be polluted from power failure.
#
> /etc/network/run/ifstate

for iface in ${INTERFACES[*]}; do
	ifup_out=`/sbin/ifup $iface 2>&1`
	ifup_res=$?
	echo -n "    $iface  "
	if [ -n "$ifup_out" ]; then
		echo -e "\t \e[31m failed \e[0m \t-->  $ifup_out"
	else
		echo -e "\t \e[32m ok \e[0m"
	fi
done
