blob: 39734dbf2362902e657a43e5b4fc7857d4d42777 [file] [log] [blame]
#!/bin/ash
NIC='0'
MAC=`cat "#ether/ether$NIC/addr"`
export cputype=amd64
export objtype=$cputype
export service=cpu
export authid=bootes
export rootdir=/root
export rootspec=''
export rootsrv=boot
if [ -f /etc/network/default ]
then
source /etc/network/default
else
echo '/etc/network/default not found'
fi
if [ -f /etc/network/local ]
then
source /etc/network/local
else
echo '/etc/network/local not found'
fi
if [ -d /etc/network/local.d ]
then
for cfg in /etc/network/local.d/*
do
source $cfg
done
else
echo '/etc/network/local.d not found'
fi
#
# Set up the initial namespace for starting networking.
#
/bin/bind -b '#cons' /dev
/bin/bind -b '#random' /dev
#/bin/bind '#d' /fd
#/bin/bind -c '#e' /env
/bin/bind -b '#proc' /proc
/bin/bind -b '#srv' /srv
#
# Configure the network mount point.
#
/bin/bind -a '#ip' /net
/bin/bind -a '#ether'.$NIC /net
if [ -x /bin/ipconfig ]
then
if [ ! -z "$me" ]
then
ipconfig -g $route ether /net/ether$NIC $me $mask
else
# No explicit configuration; use DHCP.
ipconfig ether /net/ether$NIC
fi
ipconfig loopback /dev/null 127.0.0.1
else
if [ -z "$me" ]
then
# By default, configure for QEMU.
me='10.0.2.15'
mask='255.255.255.0'
remote='10.0.2.0'
route='10.0.2.2'
fi
#
# Get an instance of an IP stack and bind ether$NIC to it.
# The kernel sets errno but 'echo' doesn't return any sort of
# error indicator. Our busybox hacks doesn't know any better
# and will think it was an error so direct stderr to /dev/null.
#
i=`cat /net/ipifc/clone`
echo "bind ether /net/ether$NIC" >/net/ipifc/$i/ctl 2>/dev/null
#
# Configure the stack.
#
echo "add $me $mask $remote" > /net/ipifc/$i/ctl
echo "add 0 0 $route" > /net/iproute
echo "I am $me, default route $route"
#
# Configure the loopback interface.
#
i=`cat /net/ipifc/clone`
echo 'bind loopback /dev/null' > /net/ipifc/$i/ctl
echo 'add 127.0.0.1 255.0.0.0 127.0.0.0' > /net/ipifc/$i/ctl
fi
#
# Start cs (the name resolution server) and wait for it to post a
# file descriptor in #srv, then mount it in /net.
#
cs &
if [ ! -e '#srv/cs' ]
then
echo 'cs has not created #srv/cs yet, spinning until it does....'
until [ -e '#srv/cs' ]
do
usleep 1000
done
fi
mount -a '#srv/cs' /net
# This is noisy, so it is off by default.
#echo debug > /net/cs
/bin/bind -a '#kprof' /prof
echo 'ifconfig complete'