Use standard ifcfg filenames, put them into an ifcfg directory.

master
Warren Togami 2009-07-27 15:54:21 -04:00
parent 0c39f9f6f6
commit 645bde35d3
2 changed files with 21 additions and 19 deletions

View File

@ -8,42 +8,43 @@ udevadm settle --timeout=30
read IFACES < /tmp/net.ifaces

for netif in $IFACES ; do
mkdir -p /tmp/ifcfg/
# bridge?
unset bridge
if [ "$netif" = "$bridgename" ]; then
bridge=yes
fi
cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
echo "# Generated by dracut initrd" > /tmp/net.$netif.ifcfg
echo "DEVICE=$netif" >> /tmp/net.$netif.ifcfg
echo "ONBOOT=yes" >> /tmp/net.$netif.ifcfg
echo "# Generated by dracut initrd" > /tmp/ifcfg/ifcfg-$netif
echo "DEVICE=$netif" >> /tmp/ifcfg/ifcfg-$netif
echo "ONBOOT=yes" >> /tmp/ifcfg/ifcfg-$netif
if [ -f /tmp/net.$netif.lease ]; then
echo "BOOTPROTO=dhcp" >> /tmp/net.$netif.ifcfg
echo "BOOTPROTO=dhcp" >> /tmp/ifcfg/ifcfg-$netif
else
echo "BOOTPROTO=none" >> /tmp/net.$netif.ifcfg
echo "BOOTPROTO=none" >> /tmp/ifcfg/ifcfg-$netif
# If we've booted with static ip= lines, the override file is there
. /tmp/net.$netif.override
echo "IPADDR=$ip" >> /tmp/net.$netif.ifcfg
echo "NETMASK=$mask" >> /tmp/net.$netif.ifcfg
[ -n "$gw" ] && echo "GATEWAY=$gw" >> /tmp/net.$netif.ifcfg
echo "IPADDR=$ip" >> /tmp/ifcfg/ifcfg-$netif
echo "NETMASK=$mask" >> /tmp/ifcfg/ifcfg-$netif
[ -n "$gw" ] && echo "GATEWAY=$gw" >> /tmp/ifcfg/ifcfg-$netif
fi

# bridge needs differente things written to ifcfg
if [ -z "$bridge" ]; then
# standard interface
echo "HWADDR=$(cat /sys/class/net/$netif/address)" >> /tmp/net.$netif.ifcfg
echo "TYPE=Ethernet" >> /tmp/net.$netif.ifcfg
echo "NAME=\"Boot Disk\"" >> /tmp/net.$netif.ifcfg
echo "HWADDR=$(cat /sys/class/net/$netif/address)" >> /tmp/ifcfg/ifcfg-$netif
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$netif
echo "NAME=\"Boot Disk\"" >> /tmp/ifcfg/ifcfg-$netif
else
# bridge
echo "TYPE=Bridge" >> /tmp/net.$netif.ifcfg
echo "NAME=\"Boot Disk\"" >> /tmp/net.$netif.ifcfg
echo "TYPE=Bridge" >> /tmp/ifcfg/ifcfg-$netif
echo "NAME=\"Boot Disk\"" >> /tmp/ifcfg/ifcfg-$netif
# write separate ifcfg file for the raw eth interface
echo "DEVICE=$ethname" >> /tmp/net.$ethname.ifcfg
echo "TYPE=Ethernet" >> /tmp/net.$ethname.ifcfg
echo "ONBOOT=yes" >> /tmp/net.$ethname.ifcfg
echo "HWADDR=$(cat /sys/class/net/$ethname/address)" >> /tmp/net.$ethname.ifcfg
echo "BRIDGE=$netif" >> /tmp/net.$ethname.ifcfg
echo "NAME=$ethname" >> /tmp/net.$ethname.ifcfg
echo "DEVICE=$ethname" >> /tmp/ifcfg/ifcfg-$ethname
echo "TYPE=Ethernet" >> /tmp/ifcfg/ifcfg-$ethname
echo "ONBOOT=yes" >> /tmp/ifcfg/ifcfg-$ethname
echo "HWADDR=$(cat /sys/class/net/$ethname/address)" >> /tmp/ifcfg/ifcfg-$ethname
echo "BRIDGE=$netif" >> /tmp/ifcfg/ifcfg-$ethname
echo "NAME=$ethname" >> /tmp/ifcfg/ifcfg-$ethname
fi
done

View File

@ -223,6 +223,7 @@ if getarg rdcopystate; then
cp /tmp/* /dev/.initramfs/ >/dev/null 2>&1
else
cp /tmp/net.* /dev/.initramfs/ >/dev/null 2>&1
cp -a /tmp/ifcfg/ /dev/.initramfs/ >/dev/null 2>&1
fi

exec switch_root "$NEWROOT" "$INIT" $initargs || {