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
8 if [ -e /tmp
/bridge.info
]; then
12 if [ -e /tmp
/vlan.info
]; then
16 mkdir
-m 0755 -p /tmp
/ifcfg
/
17 mkdir
-m 0755 -p /tmp
/ifcfg-leases
/
19 get_config_line_by_subchannel
()
26 if strstr
"$line" "$CHANNELS"; then
45 # if we find ccw channel, then use those, instead of
48 for i
in /sys
/class
/net
/$_netif/device
/cdev
[0-9]*; do
50 channel
=$
(readlink
-f $i)
51 echo -n "${channel##*/},"
54 [ -n "$SUBCHANNELS" ] ||
return 1
56 SUBCHANNELS
=${SUBCHANNELS%,}
57 echo "SUBCHANNELS=\"${SUBCHANNELS}\""
59 CONFIG_LINE
=$
(get_config_line_by_subchannel
$SUBCHANNELS)
60 [ $?
-ne 0 -o -z "$CONFIG_LINE" ] && return 0
71 while [ $# -gt 0 ]; do
73 *=*) OPTIONS
="$OPTIONS $1";;
78 echo "NETTYPE=\"${NETTYPE}\""
79 echo "OPTIONS=\"${OPTIONS}\""
83 for netup
in /tmp
/net.
*.did-setup
; do
84 [ -f $netup ] ||
continue
86 netif
=${netup%%.did-setup}
87 netif
=${netif##*/net.}
88 strglobin
"$netif" ":*:*:*:*:" && continue
89 [ -e /tmp
/ifcfg
/ifcfg-
$netif ] && continue
103 [ -e /tmp
/bond.
${netif}.info
] && .
/tmp
/bond.
${netif}.info
105 uuid
=$
(cat /proc
/sys
/kernel
/random
/uuid
)
106 if [ "$netif" = "$bridgename" ]; then
108 elif [ "$netif" = "$bondname" ]; then
109 # $netif can't be bridge and bond at the same time
112 if [ "$netif" = "$vlanname" ]; then
115 [ -e /sys
/class
/net
/$netif/address
] && \
116 cat /sys
/class
/net
/$netif/address
> /tmp
/net.
$netif.hwaddr
118 echo "# Generated by dracut initrd"
119 echo "DEVICE=\"$netif\""
122 echo "UUID=\"$uuid\""
123 if [ -f /tmp
/dhclient.
$netif.lease
]; then
124 [ -f /tmp
/dhclient.
$netif.dhcpopts
] && .
/tmp
/dhclient.
$netif.dhcpopts
125 strstr
"$(ip -6 addr show dev $netif)" 'inet6' && echo "IPV6INIT=yes"
126 if [ -f /tmp
/net.
$netif.has_ibft_config
]; then
127 echo "BOOTPROTO=ibft"
129 echo "BOOTPROTO=dhcp"
131 cp /tmp
/dhclient.
$netif.lease
/tmp
/ifcfg-leases
/dhclient-
$uuid-$netif.lease
133 # If we've booted with static ip= lines, the override file is there
134 [ -e /tmp
/net.
$netif.override
] && .
/tmp
/net.
$netif.override
135 if strglobin
"$ip" '*:*:*'; then
137 echo "IPV6_AUTOCONF=no"
138 echo "IPV6ADDR=\"$ip/$mask\""
140 if [ -f /tmp
/net.
$netif.has_ibft_config
]; then
141 echo "BOOTPROTO=ibft"
143 echo "BOOTPROTO=none"
144 echo "IPADDR=\"$ip\""
145 if strstr
"$mask" "."; then
146 echo "NETMASK=\"$mask\""
148 echo "PREFIX=\"$mask\""
152 if strglobin
"$gw" '*:*:*'; then
153 echo "IPV6_DEFAULTGW=\"$gw\""
154 elif [ -n "$gw" ]; then
155 echo "GATEWAY=\"$gw\""
158 [ -n "$mtu" ] && echo "MTU=\"$mtu\""
159 } > /tmp
/ifcfg
/ifcfg-
$netif
161 # bridge needs different things written to ifcfg
162 if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ]; then
165 [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
166 if ! print_s390
$netif; then
167 if [ -z "$macaddr" ] && \
168 ! is_persistent_ethernet_name
"$netif" && \
169 [ -f /sys
/class
/net
/$netif/addr_assign_type
] && \
170 [ "$(cat /sys/class/net/$netif/addr_assign_type)" = "0" ] && \
171 [ -f /sys
/class
/net
/$netif/address
]; then
172 echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
176 echo "NAME=\"$netif\""
177 [ -n "$mtu" ] && echo "MTU=\"$mtu\""
178 } >> /tmp
/ifcfg
/ifcfg-
$netif
181 if [ -n "$vlan" ] ; then
184 echo "NAME=\"$netif\""
186 echo "PHYSDEV=\"$phydevice\""
187 } >> /tmp
/ifcfg
/ifcfg-
$netif
190 if [ -n "$bond" ] ; then
193 # This variable is an indicator of a bond interface for initscripts
194 echo "BONDING_OPTS=\"$bondoptions\""
195 echo "NAME=\"$netif\""
197 } >> /tmp
/ifcfg
/ifcfg-
$netif
199 for slave
in $bondslaves ; do
200 # write separate ifcfg file for the raw eth interface
202 echo "# Generated by dracut initrd"
203 echo "DEVICE=\"$slave\""
207 echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
209 echo "MASTER=\"$netif\""
210 echo "NAME=\"$slave\""
211 } >> /tmp
/ifcfg
/ifcfg-
$slave
215 if [ -n "$bridge" ] ; then
219 echo "NAME=\"$netif\""
220 } >> /tmp
/ifcfg
/ifcfg-
$netif
221 if [ "$ethname" = "$bondname" ] ; then
223 echo "# Generated by dracut initrd"
224 echo "DEVICE=\"$bondname\""
227 # This variable is an indicator of a bond interface for initscripts
228 echo "BONDING_OPTS=\"$bondoptions\""
229 echo "BRIDGE=\"$netif\""
230 echo "NAME=\"$bondname\""
231 } >> /tmp
/ifcfg
/ifcfg-
$bondname
232 for slave
in $bondslaves ; do
233 # write separate ifcfg file for the raw eth interface
235 echo "# Generated by dracut initrd"
236 echo "DEVICE=\"$slave\""
240 echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
242 echo "MASTER=\"$bondname\""
243 echo "NAME=\"$slave\""
244 } >> /tmp
/ifcfg
/ifcfg-
$slave
247 # write separate ifcfg file for the raw eth interface
249 echo "# Generated by dracut initrd"
250 echo "DEVICE=\"$ethname\""
254 echo "HWADDR=\"$(cat /sys/class/net/$ethname/address)\""
255 echo "BRIDGE=\"$netif\""
256 echo "NAME=\"$ethname\""
257 } >> /tmp
/ifcfg
/ifcfg-
$ethname
261 for ns
in $
(getargs nameserver
); do
262 echo "DNS${i}=\"${ns}\"" >> /tmp
/ifcfg
/ifcfg-
$netif
268 mkdir
-m 0755 -p /run
/initramfs
/state
/etc
/sysconfig
/network-scripts
269 mkdir
-m 0755 -p /run
/initramfs
/state
/var
/lib
/dhclient
270 echo "files /etc/sysconfig/network-scripts" >> /run
/initramfs
/rwtab
271 echo "files /var/lib/dhclient" >> /run
/initramfs
/rwtab
273 cp /tmp
/net.
* /run
/initramfs
/
274 cp /tmp
/net.
$netif.resolv.conf
/run
/initramfs
/state
/etc
/resolv.conf
275 copytree
/tmp
/ifcfg
/run
/initramfs
/state
/etc
/sysconfig
/network-scripts
276 cp /tmp
/ifcfg-leases
/* /run
/initramfs
/state
/var
/lib
/dhclient