]>
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
53 if strstr
"$mask" "."; then
58 [ -n "$gw" ] && echo "GATEWAY=$gw"
60 } > /tmp
/ifcfg
/ifcfg-
$netif
62 # bridge needs different things written to ifcfg
63 if [ -z "$bridge" ] && [ -z "$bond" ]; then
66 echo "HWADDR=$(cat /sys/class/net/$netif/address)"
68 echo "NAME=\"Boot Disk\""
69 [ -n "$mtu" ] && echo "MTU=$mtu"
70 } >> /tmp
/ifcfg
/ifcfg-
$netif
73 if [ -n "$bond" ] ; then
76 # This variable is an indicator of a bond interface for initscripts
77 echo "BONDING_OPTS=\"$bondoptions\""
78 echo "NAME=\"Boot Disk\""
79 } >> /tmp
/ifcfg
/ifcfg-
$netif
81 for slave
in $bondslaves ; do
82 # Set ONBOOT=no to prevent initscripts from trying to setup already bonded physical interface
83 # write separate ifcfg file for the raw eth interface
85 echo "# Generated by dracut initrd"
90 echo "HWADDR=$(cat /sys/class/net/$slave/address)"
94 } >> /tmp
/ifcfg
/ifcfg-
$slave
98 if [ -n "$bridge" ] ; then
102 echo "NAME=\"Boot Disk\""
103 } >> /tmp
/ifcfg
/ifcfg-
$netif
104 if [ "$ethname" = "$bondname" ] ; then
106 # Set ONBOOT=no to prevent initscripts from trying to setup already bridged bond interface
107 echo "# Generated by dracut initrd"
108 echo "DEVICE=$bondname"
111 # This variable is an indicator of a bond interface for initscripts
112 echo "BONDING_OPTS=\"$bondoptions\""
114 echo "NAME=\"$bondname\""
115 } >> /tmp
/ifcfg
/ifcfg-
$bondname
116 for slave
in $bondslaves ; do
117 # write separate ifcfg file for the raw eth interface
118 # Set ONBOOT=no to prevent initscripts from trying to setup already bridged physical interface
120 echo "# Generated by dracut initrd"
125 echo "HWADDR=$(cat /sys/class/net/$slave/address)"
127 echo "MASTER=$bondname"
129 } >> /tmp
/ifcfg
/ifcfg-
$slave
132 # write separate ifcfg file for the raw eth interface
134 echo "# Generated by dracut initrd"
135 echo "DEVICE=$ethname"
139 echo "HWADDR=$(cat /sys/class/net/$ethname/address)"
142 } >> /tmp
/ifcfg
/ifcfg-
$ethname
146 for ns
in $
(getargs nameserver
); do
147 echo "DNS${i}=${ns}" >> /tmp
/ifcfg
/ifcfg-
$netif
153 mkdir
-m 0755 -p /run
/initramfs
/state
/etc
/sysconfig
/network-scripts
154 mkdir
-m 0755 -p /run
/initramfs
/state
/var
/lib
/dhclient
155 echo "files /etc/sysconfig/network-scripts" >> /run
/initramfs
/rwtab
156 echo "files /var/lib/dhclient" >> /run
/initramfs
/rwtab
158 cp /tmp
/net.
* /run
/initramfs
/
159 cp /tmp
/net.
$netif.resolv.conf
/run
/initramfs
/state
/etc
/resolv.conf
160 cp -a -t /run
/initramfs
/state
/etc
/sysconfig
/network-scripts
/ /tmp
/ifcfg
/*
161 cp /tmp
/ifcfg-leases
/* /run
/initramfs
/state
/var
/lib
/dhclient