]>
git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/45ifcfg/write-ifcfg.sh
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
5 # NFS root might have reached here before /tmp/net.ifaces was written
6 udevadm settle
--timeout=30
7 # Don't write anything if we don't know our bootdev
8 [ -f /tmp
/net.ifaces
] ||
return 1
10 read IFACES
< /tmp
/net.ifaces
12 if [ -e /tmp
/bond.info
]; then
16 if [ -e /tmp
/bridge.info
]; then
20 mkdir
-m 0755 -p /tmp
/ifcfg
/
21 mkdir
-m 0755 -p /tmp
/ifcfg-leases
/
23 for netif
in $IFACES ; do
27 uuid
=$
(cat /proc
/sys
/kernel
/random
/uuid
)
28 if [ "$netif" = "$bridgename" ]; then
30 elif [ "$netif" = "$bondname" ]; then
31 # $netif can't be bridge and bond at the same time
34 cat /sys
/class
/net
/$netif/address
> /tmp
/net.
$netif.hwaddr
36 echo "# Generated by dracut initrd"
41 if [ -f /tmp
/net.
$netif.lease
]; then
42 strstr
"$ip" '*:*:*' &&
45 cp /tmp
/net.
$netif.lease
/tmp
/ifcfg-leases
/dhclient-
$uuid-$netif.lease
48 # If we've booted with static ip= lines, the override file is there
49 [ -e /tmp
/net.
$netif.override
] && .
/tmp
/net.
$netif.override
52 [ -n "$gw" ] && echo "GATEWAY=$gw"
54 } > /tmp
/ifcfg
/ifcfg-
$netif
56 # bridge needs different things written to ifcfg
57 if [ -z "$bridge" ] && [ -z "$bond" ]; then
60 echo "HWADDR=$(cat /sys/class/net/$netif/address)"
62 echo "NAME=\"Boot Disk\""
63 } >> /tmp
/ifcfg
/ifcfg-
$netif
66 if [ -n "$bond" ] ; then
69 # This variable is an indicator of a bond interface for initscripts
70 echo "BONDING_OPTS=\"$bondoptions\""
71 echo "NAME=\"Boot Disk\""
72 } >> /tmp
/ifcfg
/ifcfg-
$netif
74 for slave
in $bondslaves ; do
75 # Set ONBOOT=no to prevent initscripts from trying to setup already bonded physical interface
76 # write separate ifcfg file for the raw eth interface
78 echo "# Generated by dracut initrd"
83 echo "HWADDR=$(cat /sys/class/net/$slave/address)"
87 } >> /tmp
/ifcfg
/ifcfg-
$slave
91 if [ -n "$bridge" ] ; then
95 echo "NAME=\"Boot Disk\""
96 } >> /tmp
/ifcfg
/ifcfg-
$netif
97 if [ "$ethname" = "$bondname" ] ; then
99 # Set ONBOOT=no to prevent initscripts from trying to setup already bridged bond interface
100 echo "# Generated by dracut initrd"
101 echo "DEVICE=$bondname"
104 # This variable is an indicator of a bond interface for initscripts
105 echo "BONDING_OPTS=\"$bondoptions\""
107 echo "NAME=\"$bondname\""
108 } >> /tmp
/ifcfg
/ifcfg-
$bondname
109 for slave
in $bondslaves ; do
110 # write separate ifcfg file for the raw eth interface
111 # Set ONBOOT=no to prevent initscripts from trying to setup already bridged physical interface
113 echo "# Generated by dracut initrd"
118 echo "HWADDR=$(cat /sys/class/net/$slave/address)"
120 echo "MASTER=$bondname"
122 } >> /tmp
/ifcfg
/ifcfg-
$slave
125 # write separate ifcfg file for the raw eth interface
127 echo "# Generated by dracut initrd"
128 echo "DEVICE=$ethname"
132 echo "HWADDR=$(cat /sys/class/net/$ethname/address)"
135 } >> /tmp
/ifcfg
/ifcfg-
$ethname
141 mkdir
-m 0755 -p /run
/initramfs
/state
/etc
/sysconfig
/network-scripts
142 mkdir
-m 0755 -p /run
/initramfs
/state
/var
/lib
/dhclient
143 echo "files /etc/sysconfig/network-scripts" >> /run
/initramfs
/rwtab
144 echo "files /var/lib/dhclient" >> /run
/initramfs
/rwtab
146 cp /tmp
/net.
* /run
/initramfs
/
147 cp /tmp
/net.
$netif.resolv.conf
/run
/initramfs
/state
/etc
/
148 cp -a -t /run
/initramfs
/state
/etc
/sysconfig
/network-scripts
/ /tmp
/ifcfg
/*
149 cp /tmp
/ifcfg-leases
/* /run
/initramfs
/state
/var
/lib
/dhclient