3 # NFS root might have reached here before /tmp/net.ifaces was written
4 type is_persistent_ethernet_name
> /dev
/null
2>&1 || .
/lib
/net-lib.sh
6 udevadm settle
--timeout=30
8 # shellcheck disable=SC2174
9 mkdir
-m 0755 -p /tmp
/ifcfg
/
10 # shellcheck disable=SC2174
11 mkdir
-m 0755 -p /tmp
/ifcfg-leases
/
13 get_config_line_by_subchannel
() {
18 while read -r line ||
[ -n "$line" ]; do
19 if strstr
"$line" "$CHANNELS"; then
38 # if we find ccw channel, then use those, instead of
41 for i
in /sys
/class
/net
/"$_netif"/device
/cdev
[0-9]*; do
42 [ -e "$i" ] ||
continue
43 channel
=$
(readlink
-f "$i")
44 printf '%s' "${channel##*/},"
47 [ -n "$SUBCHANNELS" ] ||
return 1
49 SUBCHANNELS
=${SUBCHANNELS%,}
50 echo "SUBCHANNELS=\"${SUBCHANNELS}\""
52 CONFIG_LINE
=$
(get_config_line_by_subchannel
"$SUBCHANNELS")
53 # shellcheck disable=SC2181
54 [ $?
-ne 0 -o -z "$CONFIG_LINE" ] && return 0
58 # shellcheck disable=SC2086
66 while [ $# -gt 0 ]; do
68 *=*) OPTIONS
="$OPTIONS $1" ;;
73 echo "NETTYPE=\"${NETTYPE}\""
74 echo "OPTIONS=\"${OPTIONS}\""
83 && echo "MACADDR=\"$_macaddr\""
85 print_s390
"$_netif" \
88 [ -n "$_macaddr" ] && return 0
90 is_persistent_ethernet_name
"$_netif" && return 0
92 [ -f "/sys/class/net/$_netif/addr_assign_type" ] \
93 && [ "$(cat "/sys
/class
/net
/$_netif/addr_assign_type
")" != "0" ] \
96 [ -f "/sys/class/net/$_netif/address" ] \
99 echo "HWADDR=\"$(cat /sys/class/net/"$_netif"/address)\""
106 if [ ! -e "/sys/class/net/$_netif" ]; then
107 warn
"Cannot find network interface '$_netif'!"
111 # see, if we can bind it to some hw parms
112 if hw_bind
"$_netif" "$_macaddr"; then
113 # only print out DEVICE, if it's user assigned
114 is_kernel_ethernet_name
"$_netif" && return 0
117 echo "DEVICE=\"$_netif\""
120 for netup
in /tmp
/net.
*.did-setup
; do
121 [ -f "$netup" ] ||
continue
123 netif
=${netup%%.did-setup}
124 netif
=${netif##*/net.}
125 strglobin
"$netif" ":*:*:*:*:" && continue
126 [ -e /tmp
/ifcfg
/ifcfg-
"$netif" ] && continue
147 # shellcheck disable=SC1090
148 [ -e /tmp
/bond.
"${netif}".info
] && .
/tmp
/bond.
"${netif}".info
149 # shellcheck disable=SC1090
150 [ -e /tmp
/bridge.
"${netif}".info
] && .
/tmp
/bridge.
"${netif}".info
151 # shellcheck disable=SC1090
152 [ -e /tmp
/team.
"${netif}".info
] && .
/tmp
/team.
"${netif}".info
154 read -r uuid
< /proc
/sys
/kernel
/random
/uuid
155 if [ "$netif" = "$bridgename" ]; then
157 elif [ "$netif" = "$teammaster" ]; then
159 elif [ "$netif" = "$bondname" ]; then
160 # $netif can't be bridge and bond at the same time
164 for i
in "/tmp/vlan.${netif}."*; do
165 [ ! -e "$i" ] && continue
166 # shellcheck disable=SC1090
172 # skip team interfaces for now, the host config must be in sync
173 [ "$netif" = "$teammaster" ] && continue
176 echo "# Generated by dracut initrd"
177 echo "NAME=\"$netif\""
178 [ -z "$vlan" ] && interface_bind
"$netif" "$macaddr"
181 echo "UUID=\"$uuid\""
182 strstr
"$(ip -6 addr show dev "$netif")" 'inet6' && echo "IPV6INIT=yes"
183 if [ -f /tmp
/dhclient.
"$netif".lease
]; then
184 # shellcheck disable=SC1090
185 [ -f /tmp
/dhclient.
"$netif".dhcpopts
] && .
/tmp
/dhclient.
"$netif".dhcpopts
186 if [ -f /tmp
/net.
"$netif".has_ibft_config
]; then
187 echo "BOOTPROTO=ibft"
189 echo "BOOTPROTO=dhcp"
191 cp /tmp
/dhclient.
"$netif".lease
/tmp
/ifcfg-leases
/dhclient-
"$uuid"-"$netif".lease
193 # If we've booted with static ip= lines, the override file is there
194 # shellcheck disable=SC1090
195 [ -e /tmp
/net.
"$netif".override
] && .
/tmp
/net.
"$netif".override
196 if strglobin
"$ip" '*:*:*'; then
198 echo "IPV6_AUTOCONF=no"
199 echo "IPV6ADDR=\"$ip/$mask\""
201 if [ -f /tmp
/net.
"$netif".has_ibft_config
]; then
202 echo "BOOTPROTO=ibft"
204 echo "BOOTPROTO=none"
205 echo "IPADDR=\"$ip\""
206 if strstr
"$mask" "."; then
207 echo "NETMASK=\"$mask\""
209 echo "PREFIX=\"$mask\""
213 if strglobin
"$gw" '*:*:*'; then
214 echo "IPV6_DEFAULTGW=\"$gw\""
215 elif [ -n "$gw" ]; then
216 echo "GATEWAY=\"$gw\""
219 [ -n "$mtu" ] && echo "MTU=\"$mtu\""
220 } > /tmp
/ifcfg
/ifcfg-
"$netif"
222 # bridge needs different things written to ifcfg
223 if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ] && [ -z "$team" ]; then
225 echo "TYPE=Ethernet" >> /tmp
/ifcfg
/ifcfg-
"$netif"
228 if [ -n "$vlan" ]; then
231 echo "DEVICE=\"$netif\""
233 echo "PHYSDEV=\"$phydevice\""
234 } >> /tmp
/ifcfg
/ifcfg-
"$netif"
237 if [ -n "$bond" ]; then
240 # This variable is an indicator of a bond interface for initscripts
241 echo "BONDING_OPTS=\"$bondoptions\""
242 echo "NAME=\"$netif\""
244 } >> /tmp
/ifcfg
/ifcfg-
"$netif"
246 for slave
in $bondslaves; do
247 # write separate ifcfg file for the raw eth interface
249 echo "# Generated by dracut initrd"
250 echo "NAME=\"$slave\""
255 echo "MASTER=\"$netif\""
256 echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
258 # shellcheck disable=SC1090
259 [ -e /tmp
/net.
"$slave".override
] && .
/tmp
/net.
"$slave".override
260 interface_bind
"$slave" "$macaddr"
261 ) >> /tmp
/ifcfg
/ifcfg-
"$slave"
265 if [ -n "$bridge" ]; then
269 echo "NAME=\"$netif\""
270 } >> /tmp
/ifcfg
/ifcfg-
"$netif"
271 for slave
in $bridgeslaves; do
272 # write separate ifcfg file for the raw eth interface
274 echo "# Generated by dracut initrd"
275 echo "NAME=\"$slave\""
279 echo "BRIDGE=\"$bridgename\""
280 echo "UUID=\"$(cat /proc/sys/kernel/random/uuid)\""
282 # shellcheck disable=SC1090
283 [ -e /tmp
/net.
"$slave".override
] && .
/tmp
/net.
"$slave".override
284 interface_bind
"$slave" "$macaddr"
285 ) >> /tmp
/ifcfg
/ifcfg-
"$slave"
289 for ns
in $
(getargs nameserver
) $dns1 $dns2; do
290 echo "DNS${i}=\"${ns}\"" >> /tmp
/ifcfg
/ifcfg-
"$netif"
294 [ -f /tmp
/net.route6.
"$netif" ] && cp /tmp
/net.route6.
"$netif" /tmp
/ifcfg
/route6-
"$netif"
295 [ -f /tmp
/net.route.
"$netif" ] && cp /tmp
/net.route.
"$netif" /tmp
/ifcfg
/route-
"$netif"
299 mkdir
-m 0755 -p /run
/initramfs
/state
/etc
/sysconfig
/network-scripts
300 mkdir
-m 0755 -p /run
/initramfs
/state
/var
/lib
/dhclient
301 echo "files /etc/sysconfig/network-scripts" >> /run
/initramfs
/rwtab
302 echo "files /var/lib/dhclient" >> /run
/initramfs
/rwtab
304 cp /tmp
/net.
* /run
/initramfs
/
305 for i
in /tmp
/net.
*.resolv.conf
; do
306 [ -f "$i" ] && cat "$i"
307 done |
awk '!($0 in a) { a[$0]; print }' > /run
/initramfs
/state
/etc
/resolv.conf
308 [ -s /run
/initramfs
/state
/etc
/resolv.conf
] ||
rm -f /run
/initramfs
/state
/etc
/resolv.conf
309 copytree
/tmp
/ifcfg
/run
/initramfs
/state
/etc
/sysconfig
/network-scripts
310 cp /tmp
/ifcfg-leases
/* /run
/initramfs
/state
/var
/lib
/dhclient