#!/bin/sh

preinit_ip() {
	# if the preinit interface isn't specified and ifname is set in
	# preinit.arch use that interface
	if [ -z "$pi_ifname" ]; then
		pi_ifname=$ifname
	fi

	[ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && {
		ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up

		local try=0;
		while [ $((try++)) -le 5 ] && [ ! $(cat /sys/class/net/$pi_ifname/operstate) == "up" ]; do sleep 1; done
	}
}
