|
|
|
#!/bin/sh
|
|
|
|
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
|
|
|
|
# ex: ts=8 sw=4 sts=4 et filetype=sh
|
|
|
|
|
|
|
|
# pxelinux provides macaddr '-' separated, but we need ':'
|
|
|
|
fix_bootif() {
|
|
|
|
local macaddr=${1}
|
|
|
|
local IFS='-'
|
|
|
|
macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
|
|
|
|
macaddr=${macaddr%:}
|
|
|
|
# strip hardware type field from pxelinux
|
|
|
|
[ -n "${macaddr%??:??:??:??:??:??}" ] && macaddr=${macaddr#??:}
|
|
|
|
# return macaddr with lowercase alpha characters expected by udev
|
|
|
|
echo $macaddr | sed 'y/ABCDEF/abcdef/'
|
|
|
|
}
|
|
|
|
|
|
|
|
# Don't continue if we don't need network
|
|
|
|
if [ -z "$netroot" ] && [ ! -e "/tmp/net.ifaces" ] && ! getargbool 0 rd.neednet >/dev/null; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Write udev rules
|
|
|
|
{
|
|
|
|
# bridge: attempt only the defined interface
|
|
|
|
if [ -e /tmp/bridge.info ]; then
|
|
|
|
. /tmp/bridge.info
|
|
|
|
IFACES="$IFACES ${ethnames%% *}"
|
|
|
|
MASTER_IFACES="$MASTER_IFACES $bridgename"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# bond: attempt only the defined interface (override bridge defines)
|
|
|
|
for i in /tmp/bond.*.info; do
|
|
|
|
[ -e "$i" ] || continue
|
|
|
|
unset bondslaves
|
|
|
|
unset bondname
|
|
|
|
. "$i"
|
|
|
|
# It is enough to fire up only one
|
|
|
|
IFACES="$IFACES ${bondslaves%% *}"
|
|
|
|
MASTER_IFACES="$MASTER_IFACES ${bondname}"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -e /tmp/team.info ]; then
|
|
|
|
. /tmp/team.info
|
|
|
|
IFACES="$IFACES ${teamslaves}"
|
|
|
|
MASTER_IFACES="$MASTER_IFACES ${teammaster}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e /tmp/vlan.info ]; then
|
|
|
|
. /tmp/vlan.info
|
|
|
|
IFACES="$IFACES $phydevice"
|
|
|
|
MASTER_IFACES="$MASTER_IFACES ${vlanname}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$IFACES" ]; then
|
|
|
|
[ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -e /tmp/net.bootdev ]; then
|
|
|
|
bootdev=$(cat /tmp/net.bootdev)
|
|
|
|
fi
|
|
|
|
|
|
|
|
ifup='/sbin/ifup $env{INTERFACE}'
|
|
|
|
[ -z "$netroot" ] && ifup="$ifup -m"
|
|
|
|
|
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
16 years ago
|
|
|
# BOOTIF says everything, use only that one
|
|
|
|
BOOTIF=$(getarg 'BOOTIF=')
|
|
|
|
if [ -n "$BOOTIF" ] ; then
|
|
|
|
BOOTIF=$(fix_bootif "$BOOTIF")
|
|
|
|
printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="%s"\n' "$BOOTIF" "/sbin/initqueue --onetime $ifup"
|
|
|
|
echo "[ -f /tmp/setup_net_${BOOTIF}.ok ]" >$hookdir/initqueue/finished/wait-${BOOTIF}.sh
|
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
16 years ago
|
|
|
|
|
|
|
# If we have to handle multiple interfaces, handle only them.
|
|
|
|
elif [ -n "$IFACES" ] ; then
|
|
|
|
for iface in $IFACES ; do
|
|
|
|
printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="%s"\n' "$iface" "/sbin/initqueue --onetime $ifup"
|
|
|
|
if [ "$bootdev" = "$iface" ]; then
|
|
|
|
echo "[ -f /tmp/setup_net_${iface}.ok ]" >$hookdir/initqueue/finished/wait-$iface.sh
|
|
|
|
fi
|
|
|
|
done
|
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
16 years ago
|
|
|
|
|
|
|
for iface in $MASTER_IFACES; do
|
|
|
|
if [ "$bootdev" = "$iface" ]; then
|
|
|
|
echo "[ -f /tmp/setup_net_${iface}.ok ]" >$hookdir/initqueue/finished/wait-$iface.sh
|
|
|
|
fi
|
|
|
|
done
|
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
16 years ago
|
|
|
# Default: We don't know the interface to use, handle all
|
|
|
|
# Fixme: waiting for the interface as well.
|
multinic support: Add bootdev cmdline argument
This introduces a new cmdline argument bootdev, to support the case
where multiple nics need to be up before the netroot handler is called.
Cases involved might be bonding, iscsi multipathing, bonding, ...
This argument is required to decide which interface is the primary to
use for dhcp root-path, default gw, etc.
When multiple ip= items are present on the cmdline, the ip= parser
now enforces the presence of <dev> further demands that the new argument
bootdev contains the name of the primary interface. Configurtion if of
course still delegated to netroot but in is enhance to ensure that netroot
"waits" for all required interfaces to be up.
Example: root=dhcp ip=eth0:dhcp ip=client-ip:::netmask::eth1:off bootdev=eth0
First, the ip= cmdline parser ensures that all ip items contain a <dev> then
checks the ip items and checks as well that an ip= item for the given bootdev
was found.
When the first netroot starts, probably for eth1, it checks wheter interface
configuration for all interfaces is available. If not it exits. The second
start of netroot (eth0, which was a bit delayed because of dhcp) sees that
all interfaces are present, configures them and continues.
16 years ago
|
|
|
else
|
|
|
|
# if you change the name of "91-default-net.rules", also change modules.d/80cms/cmssetup.sh
|
|
|
|
printf 'SUBSYSTEM=="net", RUN+="%s"\n' "/sbin/initqueue --onetime $ifup" > /etc/udev/rules.d/91-default-net.rules
|
|
|
|
fi
|
|
|
|
|
|
|
|
# if you change the name of "90-net.rules", also change modules.d/80cms/cmssetup.sh
|
|
|
|
} > /etc/udev/rules.d/90-net.rules
|