3 # We don't need to check for ip= errors here, that is handled by the
4 # cmdline parser script
7 # Sadly there's no easy way to split ':' separated lines into variables
12 set -- "$@" "${v%%:*}"
16 unset ip srv gw mask hostname dev autoconf
18 0) autoconf
="error" ;;
20 2) dev
=$1; autoconf
=$2 ;;
21 *) ip
=$1; srv
=$2; gw
=$3; mask
=$4; hostname
=$5; dev
=$6; autoconf
=$7 ;;
27 # /sbin/dhclient-script will mark the netif up and generate the online
29 # XXX add -V vendor class and option parsing per kernel
30 dhclient
-1 -q -cf /etc
/dhclient.conf
-pf /tmp
/dhclient.
$netif.pid
-lf /tmp
/dhclient.
$netif.lease
$netif
33 # Handle static ip configuration
36 echo ip link
set $netif up
37 echo ip addr flush dev
$netif
38 echo ip addr add
$ip/$mask dev
$netif
39 } > /tmp
/net.
$netif.up
41 [ -n "$gw" ] && echo ip route add default via
$gw dev
$netif > /tmp
/net.
$netif.gw
42 [ -n "$hostname" ] && echo hostname
$hostname > /tmp
/net.
$netif.hostname
44 echo online
> /sys
/class
/net
/$netif/uevent
47 PATH
=$PATH:/sbin
:/usr
/sbin
51 if getarg rdnetdebug
; then
52 exec >/tmp
/ifup.
$1.$$.out
53 exec 2>>/tmp
/ifup.
$1.$$.out
60 # $netif reads easier than $1
63 # bridge this interface?
64 if [ -e /tmp
/bridge.info
]; then
66 if [ "$netif" = "$ethname" ]; then
71 # bail immediately if the interface is already up
72 # or we don't need the network
73 [ -f "/tmp/net.$netif.up" ] && exit 0
74 [ -f "/tmp/root.info" ] ||
exit 0
76 [ -z "$netroot" ] && exit 0
78 # loopback is always handled the same way
79 if [ "$netif" = "lo" ] ; then
81 ip addr add
127.0.0.1/8 dev lo
86 # XXX need error handling like dhclient-script
88 # start bridge if necessary
89 if [ "$netif" = "$bridgename" ] && [ ! -e /tmp
/net.
$bridgename.up
]; then
90 ip link
set $ethname up
91 # Create bridge and add eth to bridge
92 brctl addbr
$bridgename
93 brctl setfd
$bridgename 0
94 brctl addif
$bridgename $ethname
97 # No ip lines default to dhcp
99 [ -z "$ip" ] && do_dhcp
;
101 # Specific configuration, spin through the kernel command line
102 # looking for ip= lines
103 [ "$CMDLINE" ] ||
read CMDLINE
</proc
/cmdline
;
104 for p
in $CMDLINE; do
105 [ -n "${p%ip=*}" ] && continue
108 # If this option isn't directed at our interface, skip it
109 [ -n "$dev" ] && [ "$dev" != "$netif" ] && continue
111 # Store config for later use
112 for i
in ip srv gw mask hostname
; do
113 eval '[ "$'$i'" ] && echo '$i'="$'$i'"'
114 done > /tmp
/net.
$netif.override
117 dhcp|on|any
) do_dhcp
;;