# NFS root might have reached here before /tmp/net.ifaces was written
type is_persistent_ethernet_name >/dev/null 2>&1 || . /lib/net-lib.sh
udevadm settle --timeout=30
mkdir -m 0755 -p /tmp/ifcfg/
mkdir -m 0755 -p /tmp/ifcfg-leases/
get_config_line_by_subchannel()
while read line || [ -n "$line" ]; do
if strstr "$line" "$CHANNELS"; then
# if we find ccw channel, then use those, instead of
for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
channel=$(readlink -f $i)
printf '%s' "${channel##*/},"
[ -n "$SUBCHANNELS" ] || return 1
SUBCHANNELS=${SUBCHANNELS%,}
echo "SUBCHANNELS=\"${SUBCHANNELS}\""
CONFIG_LINE=$(get_config_line_by_subchannel $SUBCHANNELS)
[ $? -ne 0 -o -z "$CONFIG_LINE" ] && return 0
*=*) OPTIONS="$OPTIONS $1";;
echo "NETTYPE=\"${NETTYPE}\""
echo "OPTIONS=\"${OPTIONS}\""
&& echo "MACADDR=\"$_macaddr\""
[ -n "$_macaddr" ] && return 0
is_persistent_ethernet_name "$_netif" && return 0
[ -f "/sys/class/net/$_netif/addr_assign_type" ] \
&& [ "$(cat "/sys/class/net/$_netif/addr_assign_type")" != "0" ] \
[ -f "/sys/class/net/$_netif/address" ] \
echo "HWADDR=\"$(cat /sys/class/net/$_netif/address)\""
if [ ! -e "/sys/class/net/$_netif" ]; then
derror "Cannot find network interface '$_netif'!"
# see, if we can bind it to some hw parms
if hw_bind "$_netif" "$_macaddr"; then
# only print out DEVICE, if it's user assigned
is_kernel_ethernet_name "$_netif" && return 0
echo "DEVICE=\"$_netif\""
for netup in /tmp/net.*.did-setup ; do
[ -f $netup ] || continue
netif=${netup%%.did-setup}
strglobin "$netif" ":*:*:*:*:" && continue
[ -e /tmp/ifcfg/ifcfg-$netif ] && continue
[ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
[ -e /tmp/bridge.${netif}.info ] && . /tmp/bridge.${netif}.info
[ -e /tmp/team.${netif}.info ] && . /tmp/team.${netif}.info
uuid=$(cat /proc/sys/kernel/random/uuid)
if [ "$netif" = "$bridgename" ]; then
elif [ "$netif" = "$teammaster" ]; then
elif [ "$netif" = "$bondname" ]; then
# $netif can't be bridge and bond at the same time
for i in /tmp/vlan.${netif}.*; do
[ ! -e "$i" ] && continue
# skip team interfaces for now, the host config must be in sync
[ "$netif" = "$teammaster" ] && continue
echo "# Generated by dracut initrd"
[ -z "$vlan" ] && interface_bind "$netif" "$macaddr"
strstr "$(ip -6 addr show dev $netif)" 'inet6' && echo "IPV6INIT=yes"
if [ -f /tmp/dhclient.$netif.lease ]; then
[ -f /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
if [ -f /tmp/net.$netif.has_ibft_config ]; then
cp /tmp/dhclient.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
# If we've booted with static ip= lines, the override file is there
[ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
if strglobin "$ip" '*:*:*'; then
echo "IPV6ADDR=\"$ip/$mask\""
if [ -f /tmp/net.$netif.has_ibft_config ]; then
if strstr "$mask" "."; then
if strglobin "$gw" '*:*:*'; then
echo "IPV6_DEFAULTGW=\"$gw\""
[ -n "$mtu" ] && echo "MTU=\"$mtu\""
} > /tmp/ifcfg/ifcfg-$netif
# bridge needs different things written to ifcfg
if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ] && [ -z "$team" ]; then
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$netif
echo "PHYSDEV=\"$phydevice\""
} >> /tmp/ifcfg/ifcfg-$netif
# This variable is an indicator of a bond interface for initscripts
echo "BONDING_OPTS=\"$bondoptions\""
} >> /tmp/ifcfg/ifcfg-$netif
for slave in $bondslaves ; do
# write separate ifcfg file for the raw eth interface
echo "# Generated by dracut initrd"
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
interface_bind "$slave" "$macaddr"
) >> /tmp/ifcfg/ifcfg-$slave
if [ -n "$bridge" ] ; then
} >> /tmp/ifcfg/ifcfg-$netif
for slave in $bridgeslaves ; do
# write separate ifcfg file for the raw eth interface
echo "# Generated by dracut initrd"
echo "BRIDGE=\"$bridgename\""
echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
[ -e /tmp/net.$slave.override ] && . /tmp/net.$slave.override
interface_bind "$slave" "$macaddr"
) >> /tmp/ifcfg/ifcfg-$slave
for ns in $(getargs nameserver) $dns1 $dns2; do
echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
[ -f /tmp/net.route6."$netif" ] && cp /tmp/net.route6."$netif" /tmp/ifcfg/route6-"$netif"
[ -f /tmp/net.route."$netif" ] && cp /tmp/net.route."$netif" /tmp/ifcfg/route-"$netif"
mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
mkdir -m 0755 -p /run/initramfs/state/var/lib/dhclient
echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
cp /tmp/net.* /run/initramfs/
for i in /tmp/net.*.resolv.conf; do
done | sort -u > /run/initramfs/state/etc/resolv.conf
[ -s /run/initramfs/state/etc/resolv.conf ] || rm -f /run/initramfs/state/etc/resolv.conf
copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient