6 # ip=<interface>:[dhcp|on|any]
8 # ip=<client-IP-number>:<server-id>:<gateway-IP-number>:<netmask>:<client-hostname>:<interface>:[dhcp|on|any|none|off]
10 # When supplying more than only ip= line, <interface> is mandatory and
11 # bootdev= must contain the name of the primary interface to use for
12 # routing,dns,dhcp-options,etc.
17 # Check if ip= lines should be used
18 if getarg ip
= >/dev
/null
; then
19 if [ -z "$netroot" ] ; then
20 echo "Warning: No netboot configured, ignoring ip= lines"
25 # Don't mix BOOTIF=macaddr from pxelinux and ip= lines
26 getarg ip
= >/dev
/null
&& getarg BOOTIF
= >/dev
/null
&& \
27 die
"Mixing BOOTIF and ip= lines is dangerous"
29 # No more parsing stuff, BOOTIF says everything
30 [ -n "$(getarg BOOTIF)" ] && return
32 if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] ; then
33 # No ip= argument(s) for netroot provided, defaulting to DHCP
37 # Count ip= lines to decide whether we need bootdev= or not
38 if [ -z "$NEEDBOOTDEV" ] ; then
40 for p
in $
(getargs ip
=); do
41 count
=$
(( $count + 1 ))
43 [ $count -gt 1 ] && NEEDBOOTDEV
=1
46 # If needed, check if bootdev= contains anything usable
47 if [ -n "$NEEDBOOTDEV" ] ; then
48 BOOTDEV
=$
(getarg bootdev
=) || die
"Please supply bootdev argument for multiple ip= lines"
49 [ -z "$BOOTDEV" ] && die
"Bootdev argument is empty"
53 # XXX Would be nice if we could errorcheck ip addresses here as well
54 for p
in $
(getargs ip
=); do
57 # We need to have an ip= line for the specified bootdev
58 [ -n "$NEEDBOOTDEV" ] && [ "$dev" = "$BOOTDEV" ] && BOOTDEVOK
=1
60 # Empty autoconf defaults to 'dhcp'
61 if [ -z "$autoconf" ] ; then
62 warn
"Empty autoconf values default to dhcp"
66 # Error checking for autoconf in combination with other values
68 error
) die
"Error parsing option 'ip=$p'";;
69 bootp|rarp|both
) die
"Sorry, ip=$autoconf is currenty unsupported";;
72 die
"For argument 'ip=$p'\nValue '$autoconf' without static configuration does not make sense"
74 die
"Sorry, automatic calculation of netmask is not yet supported"
77 [ -n "$NEEDBOOTDEV" ] && [ -z "$dev" ] && \
78 die
"Sorry, 'ip=$p' does not make sense for multiple interface configurations"
80 die
"For argument 'ip=$p'\nSorry, setting client-ip does not make sense for '$autoconf'"
82 *) die
"For argument 'ip=$p'\nSorry, unknown value '$autoconf'";;
85 if [ -n "$dev" ] ; then
86 # We don't like duplicate device configs
87 if [ -n "$IFACES" ] ; then
89 [ "$dev" = "$i" ] && die
"For argument 'ip=$p'\nDuplication configurations for '$dev'"
92 # IFACES list for later use
96 # Small optimization for udev rules
97 [ -z "$NEEDBOOTDEV" ] && [ -n "$dev" ] && BOOTDEV
=$dev
99 # Do we need to check for specific options?
100 if [ -n "$NEEDDHCP" ] ||
[ -n "$DHCPORSERVER" ] ; then
101 # Correct device? (Empty is ok as well)
102 [ "$dev" = "$BOOTDEV" ] ||
continue
103 # Server-ip is there?
104 [ -n "$DHCPORSERVER" ] && [ -n "$srv" ] && continue
105 # dhcp? (It's simpler to check for a set ip. Checks above ensure that if
106 # ip is there, we're static
107 [ -z "$ip" ] && continue
109 die
"Server-ip or dhcp for netboot needed, but current arguments say otherwise"
114 # This ensures that BOOTDEV is always first in IFACES
115 if [ -n "$BOOTDEV" ] && [ -n "$IFACES" ] ; then
116 IFACES
="${IFACES%$BOOTDEV*} ${IFACES#*$BOOTDEV}"
117 IFACES
="$BOOTDEV $IFACES"
120 # Store BOOTDEV and IFACES for later use
121 [ -n "$BOOTDEV" ] && echo $BOOTDEV > /tmp
/net.bootdev
122 [ -n "$IFACES" ] && echo $IFACES > /tmp
/net.ifaces
124 # We need a ip= line for the configured bootdev=
125 [ -n "$NEEDBOOTDEV" ] && [ -z "$BOOTDEVOK" ] && die
"Bootdev Argument '$BOOTDEV' not found"