#!/bin/ash

# bring up the ethernet; maybe should do DHCP?
ifconfig lo 127.0.0.1

network_modules="e1000 e1000e igb sfc mdio mlx4_core mlx4_en"
for module in `echo $network_modules`; do
	if [ -f /lib/modules/$module.ko ]; then
		insmod /lib/modules/$module.ko
	fi
done

if [ -e /sys/class/net/eth0 ]; then
	# Set up static IP
	if [ ! -z "$CONFIG_BOOT_STATIC_IP" ]; then
		ifconfig eth0 $CONFIG_BOOT_STATIC_IP
	fi
	# TODO: Set up DHCP if available
	ifconfig eth0 > /dev/ttyprintk

	# Set up the ssh server, allow root logins and log to stderr
	if [ ! -d /etc/dropbear ]; then
		mkdir /etc/dropbear
	fi
	dropbear -B -R 2>/dev/ttyprintk

	ifconfig eth0 | head -1 > /dev/tty0
fi
