]>
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 [ -n "$macaddr" ] && echo "MACADDR=$macaddr"
42 [ -n "$mtu" ] && echo "MTU=$mtu"
43 if [ -f /tmp
/net.
$netif.lease
]; then
44 strstr
"$ip" '*:*:*' &&
47 cp /tmp
/net.
$netif.lease
/tmp
/ifcfg-leases
/dhclient-
$uuid-$netif.lease
50 # If we've booted with static ip= lines, the override file is there
51 [ -e /tmp
/net.
$netif.override
] && .
/tmp
/net.
$netif.override
54 [ -n "$gw" ] && echo "GATEWAY=$gw"
56 } > /tmp
/ifcfg
/ifcfg-
$netif
58 # bridge needs different things written to ifcfg
59 if [ -z "$bridge" ] && [ -z "$bond" ]; then
62 echo "HWADDR=$(cat /sys/class/net/$netif/address)"
64 echo "NAME=\"Boot Disk\""
65 [ -n "$mtu" ] && echo "MTU=$mtu"
66 } >> /tmp
/ifcfg
/ifcfg-
$netif
69 if [ -n "$bond" ] ; then
72 # This variable is an indicator of a bond interface for initscripts
73 echo "BONDING_OPTS=\"$bondoptions\""
74 echo "NAME=\"Boot Disk\""
75 } >> /tmp
/ifcfg
/ifcfg-
$netif
77 for slave
in $bondslaves ; do
78 # Set ONBOOT=no to prevent initscripts from trying to setup already bonded physical interface
79 # write separate ifcfg file for the raw eth interface
81 echo "# Generated by dracut initrd"
86 echo "HWADDR=$(cat /sys/class/net/$slave/address)"
90 } >> /tmp
/ifcfg
/ifcfg-
$slave
94 if [ -n "$bridge" ] ; then
98 echo "NAME=\"Boot Disk\""
99 } >> /tmp
/ifcfg
/ifcfg-
$netif
100 if [ "$ethname" = "$bondname" ] ; then
102 # Set ONBOOT=no to prevent initscripts from trying to setup already bridged bond interface
103 echo "# Generated by dracut initrd"
104 echo "DEVICE=$bondname"
107 # This variable is an indicator of a bond interface for initscripts
108 echo "BONDING_OPTS=\"$bondoptions\""
110 echo "NAME=\"$bondname\""
111 } >> /tmp
/ifcfg
/ifcfg-
$bondname
112 for slave
in $bondslaves ; do
113 # write separate ifcfg file for the raw eth interface
114 # Set ONBOOT=no to prevent initscripts from trying to setup already bridged physical interface
116 echo "# Generated by dracut initrd"
121 echo "HWADDR=$(cat /sys/class/net/$slave/address)"
123 echo "MASTER=$bondname"
125 } >> /tmp
/ifcfg
/ifcfg-
$slave
128 # write separate ifcfg file for the raw eth interface
130 echo "# Generated by dracut initrd"
131 echo "DEVICE=$ethname"
135 echo "HWADDR=$(cat /sys/class/net/$ethname/address)"
138 } >> /tmp
/ifcfg
/ifcfg-
$ethname
142 for ns
in $
(getargs nameserver
); do
143 echo "DNS${i}=${ns}" >> /tmp
/ifcfg
/ifcfg-
$netif
149 mkdir
-m 0755 -p /run
/initramfs
/state
/etc
/sysconfig
/network-scripts
150 mkdir
-m 0755 -p /run
/initramfs
/state
/var
/lib
/dhclient
151 echo "files /etc/sysconfig/network-scripts" >> /run
/initramfs
/rwtab
152 echo "files /var/lib/dhclient" >> /run
/initramfs
/rwtab
154 cp /tmp
/net.
* /run
/initramfs
/
155 cp /tmp
/net.
$netif.resolv.conf
/run
/initramfs
/state
/etc
/
156 cp -a -t /run
/initramfs
/state
/etc
/sysconfig
/network-scripts
/ /tmp
/ifcfg
/*
157 cp /tmp
/ifcfg-leases
/* /run
/initramfs
/state
/var
/lib
/dhclient