dracut/change_write_ifcfg_to_suse.patch
Shawn Dunn 7955a4d13a Accepting request 229484 from home:hreinecke:branches:Base:System
- Update dracut to 037
  * Add --hostonly_cmdline switch
  * Update --mount syntax
  * Include modules from /updates directory
  * Fixes for network setup
  * Some small fixes
- Rediff patches
- Include iscsiuio again (bnc#872474)
  Remove: remove-iscsiuio.patch
- Install 59-scsi-sg_utils.rules (bnc#872478)
  Add: 0015-95udev-rules-Add-59-scsi-sg_utils.rules.patch
- Install 67-kpartx-compat.rules (bnc#872662)
  Add: 0016-90multipath-add-67-kpartx-compat.rules.patch
- Install separate multipath service file (bnc#871610)
  Add: 0017-90multipath-install-dracut-specific-service-file.patch
- Do not fsck and mount from fstab if systemd is used (bnc#
  Add: 0018-fstab-do-not-mount-and-fsck-from-fstab-if-using-syst.patch
- Fixup initqueue for remote-fs
  Add: 0019-dracut-initqueue-service-runs-before-remote-fs-pre.t.patch

OBS-URL: https://build.opensuse.org/request/show/229484
OBS-URL: https://build.opensuse.org/package/show/Base:System/dracut?expand=0&rev=124
2014-04-09 12:44:32 +00:00

797 lines
25 KiB
Diff

From dc3ce2b641e458c0030476ebdd0bb86783dd98e4 Mon Sep 17 00:00:00 2001
From: Pawel Wieczorkiewicz <pwieczorkiewicz@suse.de>
Date: Tue, 8 Apr 2014 08:48:27 +0200
Subject: [PATCH] 45ifcfg: use distro-specific scripts
Detect the system flavor and write the ifcfg files accordingly.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
modules.d/40network/ifup.sh | 1 +
modules.d/45ifcfg/module-setup.sh | 8 +-
modules.d/45ifcfg/write-ifcfg-redhat.sh | 271 ++++++++++++++++++++++++++++++++
modules.d/45ifcfg/write-ifcfg-suse.sh | 183 +++++++++++++++++++++
modules.d/45ifcfg/write-ifcfg.sh | 271 --------------------------------
5 files changed, 462 insertions(+), 272 deletions(-)
create mode 100755 modules.d/45ifcfg/write-ifcfg-redhat.sh
create mode 100755 modules.d/45ifcfg/write-ifcfg-suse.sh
delete mode 100755 modules.d/45ifcfg/write-ifcfg.sh
diff --git a/modules.d/40network/ifup.sh b/modules.d/40network/ifup.sh
index 25ce094..65f5f4c 100755
--- a/modules.d/40network/ifup.sh
+++ b/modules.d/40network/ifup.sh
@@ -186,6 +186,7 @@ do_dhcp() {
$dhclient --test $netif > /tmp/leaseinfo.${netif}.dhcp.ipv${1:1:1}
dhcp_apply $1 || return $?
+ echo $netif > /tmp/net.${netif}.did-setup
echo $netif > /tmp/setup_net_${netif}.ok
return 0
}
diff --git a/modules.d/45ifcfg/module-setup.sh b/modules.d/45ifcfg/module-setup.sh
index c407f45..164a580 100755
--- a/modules.d/45ifcfg/module-setup.sh
+++ b/modules.d/45ifcfg/module-setup.sh
@@ -4,7 +4,13 @@
# called by dracut
check() {
- [[ -d /etc/sysconfig/network-scripts ]] && return 0
+ local link=$(readlink $moddir/write-ifcfg.sh)
+ [[ "$link" = "write-ifcfg-suse.sh" ]] && \
+ [[ -d /etc/sysconfig/network ]] && \
+ return 0
+ [[ "$link" = "write-ifcfg-redhat.sh" ]] && \
+ [[ -d /etc/sysconfig/network-scripts ]] && \
+ return 0
return 255
}
diff --git a/modules.d/45ifcfg/write-ifcfg-redhat.sh b/modules.d/45ifcfg/write-ifcfg-redhat.sh
new file mode 100755
index 0000000..e2fa485
--- /dev/null
+++ b/modules.d/45ifcfg/write-ifcfg-redhat.sh
@@ -0,0 +1,271 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+# NFS root might have reached here before /tmp/net.ifaces was written
+udevadm settle --timeout=30
+
+if [ -e /tmp/bridge.info ]; then
+ . /tmp/bridge.info
+fi
+
+if [ -e /tmp/vlan.info ]; then
+ . /tmp/vlan.info
+fi
+
+mkdir -m 0755 -p /tmp/ifcfg/
+mkdir -m 0755 -p /tmp/ifcfg-leases/
+
+get_config_line_by_subchannel()
+{
+ local CHANNEL
+ local line
+
+ CHANNELS="$1"
+ while read line; do
+ if strstr "$line" "$CHANNELS"; then
+ echo $line
+ return 0
+ fi
+ done < /etc/ccw.conf
+ return 1
+}
+
+print_s390() {
+ local _netif
+ local SUBCHANNELS
+ local OPTIONS
+ local NETTYPE
+ local CONFIG_LINE
+ local i
+ local channel
+ local OLD_IFS
+
+ _netif="$1"
+ # if we find ccw channel, then use those, instead of
+ # of the MAC
+ SUBCHANNELS=$({
+ for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
+ [ -e $i ] || continue
+ channel=$(readlink -f $i)
+ echo -n "${channel##*/},"
+ done
+ })
+ [ -n "$SUBCHANNELS" ] || return 1
+
+ SUBCHANNELS=${SUBCHANNELS%,}
+ echo "SUBCHANNELS=\"${SUBCHANNELS}\""
+
+ CONFIG_LINE=$(get_config_line_by_subchannel $SUBCHANNELS)
+ [ $? -ne 0 -o -z "$CONFIG_LINE" ] && return 0
+
+ OLD_IFS=$IFS
+ IFS=","
+ set -- $CONFIG_LINE
+ IFS=$OLD_IFS
+ NETTYPE=$1
+ shift
+ SUBCHANNELS="$1"
+ OPTIONS=""
+ shift
+ while [ $# -gt 0 ]; do
+ case $1 in
+ *=*) OPTIONS="$OPTIONS $1";;
+ esac
+ shift
+ done
+ OPTIONS=${OPTIONS## }
+ echo "NETTYPE=\"${NETTYPE}\""
+ echo "OPTIONS=\"${OPTIONS}\""
+ return 0
+}
+
+for netup in /tmp/net.*.did-setup ; do
+ [ -f $netup ] || continue
+
+ netif=${netup%%.did-setup}
+ netif=${netif##*/net.}
+ strstr "$netif" ":*:*:*:*:" && continue
+ [ -e /tmp/ifcfg/ifcfg-$netif ] && continue
+ unset bridge
+ unset bond
+ unset bondslaves
+ unset bondname
+ unset bondoptions
+ unset uuid
+ unset ip
+ unset gw
+ unset mtu
+ unset mask
+ unset macaddr
+ unset slave
+ unset ethname
+ [ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
+
+ uuid=$(cat /proc/sys/kernel/random/uuid)
+ if [ "$netif" = "$bridgename" ]; then
+ bridge=yes
+ elif [ "$netif" = "$bondname" ]; then
+ # $netif can't be bridge and bond at the same time
+ bond=yes
+ fi
+ if [ "$netif" = "$vlanname" ]; then
+ vlan=yes
+ fi
+ [ -e /sys/class/net/$netif/address ] && \
+ cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
+ {
+ echo "# Generated by dracut initrd"
+ echo "DEVICE=\"$netif\""
+ echo "ONBOOT=yes"
+ echo "NETBOOT=yes"
+ echo "UUID=\"$uuid\""
+ if [ -f /tmp/dhclient.$netif.lease ]; then
+ [ -f /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
+ strstr "$ip" '*:*:*' && echo "IPV6INIT=yes"
+ if [ -f /tmp/net.$netif.has_ibft_config ]; then
+ echo "BOOTPROTO=ibft"
+ else
+ echo "BOOTPROTO=dhcp"
+ fi
+ cp /tmp/dhclient.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
+ else
+ # If we've booted with static ip= lines, the override file is there
+ [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
+ if strstr "$ip" '*:*:*'; then
+ echo "IPV6INIT=yes"
+ echo "IPV6_AUTOCONF=no"
+ echo "IPV6ADDR=\"$ip/$mask\""
+ else
+ if [ -f /tmp/net.$netif.has_ibft_config ]; then
+ echo "BOOTPROTO=ibft"
+ else
+ echo "BOOTPROTO=none"
+ echo "IPADDR=\"$ip\""
+ if strstr "$mask" "."; then
+ echo "NETMASK=\"$mask\""
+ else
+ echo "PREFIX=\"$mask\""
+ fi
+ fi
+ fi
+ if strstr "$gw" '*:*:*'; then
+ echo "IPV6_DEFAULTGW=\"$gw\""
+ elif [ -n "$gw" ]; then
+ echo "GATEWAY=\"$gw\""
+ fi
+ fi
+ [ -n "$mtu" ] && echo "MTU=\"$mtu\""
+ } > /tmp/ifcfg/ifcfg-$netif
+
+ # bridge needs different things written to ifcfg
+ if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ]; then
+ # standard interface
+ {
+ [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
+ if ! print_s390 $netif; then
+ [ -n "$macaddr" ] || echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
+ fi
+ echo "TYPE=Ethernet"
+ echo "NAME=\"$netif\""
+ [ -n "$mtu" ] && echo "MTU=\"$mtu\""
+ } >> /tmp/ifcfg/ifcfg-$netif
+ fi
+
+ if [ -n "$vlan" ] ; then
+ {
+ echo "TYPE=Vlan"
+ echo "NAME=\"$netif\""
+ echo "VLAN=yes"
+ echo "PHYSDEV=\"$phydevice\""
+ } >> /tmp/ifcfg/ifcfg-$netif
+ fi
+
+ if [ -n "$bond" ] ; then
+ # bond interface
+ {
+ # This variable is an indicator of a bond interface for initscripts
+ echo "BONDING_OPTS=\"$bondoptions\""
+ echo "NAME=\"$netif\""
+ echo "TYPE=Bond"
+ } >> /tmp/ifcfg/ifcfg-$netif
+
+ for slave in $bondslaves ; do
+ # write separate ifcfg file for the raw eth interface
+ {
+ echo "# Generated by dracut initrd"
+ echo "DEVICE=\"$slave\""
+ echo "TYPE=Ethernet"
+ echo "ONBOOT=yes"
+ echo "NETBOOT=yes"
+ echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
+ echo "SLAVE=yes"
+ echo "MASTER=\"$netif\""
+ echo "NAME=\"$slave\""
+ } >> /tmp/ifcfg/ifcfg-$slave
+ done
+ fi
+
+ if [ -n "$bridge" ] ; then
+ # bridge
+ {
+ echo "TYPE=Bridge"
+ echo "NAME=\"$netif\""
+ } >> /tmp/ifcfg/ifcfg-$netif
+ if [ "$ethname" = "$bondname" ] ; then
+ {
+ echo "# Generated by dracut initrd"
+ echo "DEVICE=\"$bondname\""
+ echo "ONBOOT=yes"
+ echo "NETBOOT=yes"
+ # This variable is an indicator of a bond interface for initscripts
+ echo "BONDING_OPTS=\"$bondoptions\""
+ echo "BRIDGE=\"$netif\""
+ echo "NAME=\"$bondname\""
+ } >> /tmp/ifcfg/ifcfg-$bondname
+ for slave in $bondslaves ; do
+ # write separate ifcfg file for the raw eth interface
+ {
+ echo "# Generated by dracut initrd"
+ echo "DEVICE=\"$slave\""
+ echo "TYPE=Ethernet"
+ echo "ONBOOT=yes"
+ echo "NETBOOT=yes"
+ echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
+ echo "SLAVE=yes"
+ echo "MASTER=\"$bondname\""
+ echo "NAME=\"$slave\""
+ } >> /tmp/ifcfg/ifcfg-$slave
+ done
+ else
+ # write separate ifcfg file for the raw eth interface
+ {
+ echo "# Generated by dracut initrd"
+ echo "DEVICE=\"$ethname\""
+ echo "TYPE=Ethernet"
+ echo "ONBOOT=yes"
+ echo "NETBOOT=yes"
+ echo "HWADDR=\"$(cat /sys/class/net/$ethname/address)\""
+ echo "BRIDGE=\"$netif\""
+ echo "NAME=\"$ethname\""
+ } >> /tmp/ifcfg/ifcfg-$ethname
+ fi
+ fi
+ i=1
+ for ns in $(getargs nameserver); do
+ echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
+ i=$((i+1))
+ done
+done
+
+# Pass network opts
+mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
+mkdir -m 0755 -p /run/initramfs/state/var/lib/dhclient
+echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
+echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
+{
+ cp /tmp/net.* /run/initramfs/
+ cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
+ copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
+ cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
+} > /dev/null 2>&1
diff --git a/modules.d/45ifcfg/write-ifcfg-suse.sh b/modules.d/45ifcfg/write-ifcfg-suse.sh
new file mode 100755
index 0000000..4b6350f
--- /dev/null
+++ b/modules.d/45ifcfg/write-ifcfg-suse.sh
@@ -0,0 +1,183 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+# NFS root might have reached here before /tmp/net.ifaces was written
+udevadm settle --timeout=30
+
+if [ -e /tmp/bridge.info ]; then
+ . /tmp/bridge.info
+fi
+
+if [ -e /tmp/vlan.info ]; then
+ . /tmp/vlan.info
+fi
+
+mkdir -m 0755 -p /tmp/ifcfg/
+mkdir -m 0755 -p /tmp/ifcfg-leases/
+
+get_vid() {
+ case "$1" in
+ vlan*)
+ echo ${1#vlan}
+ ;;
+ *.*)
+ echo ${1##*.}
+ ;;
+ esac
+}
+
+for netup in /tmp/net.*.did-setup ; do
+ [ -f $netup ] || continue
+
+ netif=${netup%%.did-setup}
+ netif=${netif##*/net.}
+ [ -e /tmp/ifcfg/ifcfg-$netif ] && continue
+ unset bridge
+ unset bond
+ unset bondslaves
+ unset bondname
+ unset bondoptions
+ unset uuid
+ unset ip
+ unset gw
+ unset mtu
+ unset mask
+ unset macaddr
+ unset slave
+ unset ethname
+ [ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
+
+ uuid=$(cat /proc/sys/kernel/random/uuid)
+ if [ "$netif" = "$bridgename" ]; then
+ bridge=yes
+ elif [ "$netif" = "$bondname" ]; then
+ # $netif can't be bridge and bond at the same time
+ bond=yes
+ fi
+ if [ "$netif" = "$vlanname" ]; then
+ vlan=yes
+ fi
+ cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
+ {
+ echo "# Generated by dracut initrd"
+ echo "NAME='$netif'"
+ if [ -f /tmp/net.$netif.has_ibft_config ]; then
+ echo "STARTMODE='nfsroot'"
+ else
+ echo "STARTMODE='auto'"
+ fi
+
+ local bootproto="static"
+ if [ -f /tmp/leaseinfo.${netif}.dhcp.ipv6 ]; then
+ bootproto="dhcp6"
+ fi
+ if [ -f /tmp/leaseinfo.${netif}.dhcp.ipv4 ]; then
+ if [ "$bootproto" = "dhcp6" ]; then
+ bootproto="dhcp"
+ else
+ bootproto="dhcp4"
+ fi
+ fi
+
+ echo "BOOTPROTO='$bootproto'"
+
+ if [ "$bootproto" = "static" ]; then
+ # If we've booted with static ip= lines, the override file is there
+ [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
+ echo "IPADDR='$ip'"
+ if [ -n "$mask" ]; then
+ if strstr "$mask" "."; then
+ echo "NETMASK='$mask'"
+ else
+ echo "PREFIXLEN='$mask'"
+ fi
+ fi
+ if [ -n "$gw" ]; then
+ echo "GATEWAY='$gw'"
+ fi
+ fi
+ [ -n "$mtu" ] && echo "MTU='$mtu'"
+ } > /tmp/ifcfg/ifcfg-$netif
+
+ # bridge needs different things written to ifcfg
+ if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ]; then
+ # standard interface
+ {
+ if [ -n "$macaddr" ]; then
+ echo "LLADDR='$macaddr'"
+ else
+ echo "LLADDR='$(cat /sys/class/net/$netif/address)'"
+ fi
+ echo "INTERFACETYPE='Ethernet'"
+ } >> /tmp/ifcfg/ifcfg-$netif
+ fi
+
+ if [ -n "$vlan" ]; then
+ {
+ echo "INTERFACETYPE='Vlan'"
+ echo "VLAN_ID='$(get_vid $vlanname)'"
+ echo "ETHERDEVICE='$phydevice'"
+ } >> /tmp/ifcfg/ifcfg-$netif
+ fi
+
+ if [ -n "$bond" ] ; then
+ # bond interface
+ {
+ # This variable is an indicator of a bond interface for initscripts
+ echo "BONDING_MASTER='yes'"
+ echo "BONDING_MODULE_OPTS='$bondoptions'"
+ echo "INTERFACETYPE='Bond'"
+ } >> /tmp/ifcfg/ifcfg-$netif
+
+ local i=0
+ for slave in $bondslaves ; do
+ echo "BONDING_SLAVE_$i='$slave'" >> /tmp/ifcfg/ifcfg-$netif
+ i=$((i+1))
+ # write separate ifcfg file for the raw eth interface
+ {
+ echo "# Generated by dracut initrd"
+ echo "NAME='$slave'"
+ echo "INTERFACETYPE='Ethernet'"
+ echo "STARTMODE='hotplug'"
+ echo "BOOTPROTO='none'"
+ echo "# ETHTOOL=''"
+ } >> /tmp/ifcfg/ifcfg-$slave
+ done
+ fi
+
+ if [ -n "$bridge" ] ; then
+ # bridge
+ {
+ echo "INTERFACETYPE='Bridge'"
+ echo "BRIDGE='yes'"
+ echo "BRIDGE_STP='off'"
+ echo "BRIDGE_FORWARDDELAY='0'"
+ echo -n "BRIDGE_PORTS='"
+
+ } >> /tmp/ifcfg/ifcfg-$netif
+
+ if [ "$ethname" = "$bondname" ] ; then
+ {
+ for slave in $bondslaves ; do
+ echo -n "$bondname "
+ done
+ echo "'"
+ } >> /tmp/ifcfg/ifcfg-$netif
+ else
+ echo "$ethname'" >> /tmp/ifcfg/ifcfg-$netif
+ fi
+ fi
+done
+
+# Pass network opts
+mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network
+mkdir -m 0755 -p /run/initramfs/state/var/run/wicked
+echo "files /etc/sysconfig/network" >> /run/initramfs/rwtab
+echo "files /var/run/wicked" >> /run/initramfs/rwtab
+{
+ cp /tmp/net.* /run/initramfs/
+ cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
+ copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network
+ cp /tmp/leaseinfo.* /run/initramfs/state/var/run/wicked/
+} > /dev/null 2>&1
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
deleted file mode 100755
index e2fa485..0000000
--- a/modules.d/45ifcfg/write-ifcfg.sh
+++ /dev/null
@@ -1,271 +0,0 @@
-#!/bin/sh
-# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
-# ex: ts=8 sw=4 sts=4 et filetype=sh
-
-# NFS root might have reached here before /tmp/net.ifaces was written
-udevadm settle --timeout=30
-
-if [ -e /tmp/bridge.info ]; then
- . /tmp/bridge.info
-fi
-
-if [ -e /tmp/vlan.info ]; then
- . /tmp/vlan.info
-fi
-
-mkdir -m 0755 -p /tmp/ifcfg/
-mkdir -m 0755 -p /tmp/ifcfg-leases/
-
-get_config_line_by_subchannel()
-{
- local CHANNEL
- local line
-
- CHANNELS="$1"
- while read line; do
- if strstr "$line" "$CHANNELS"; then
- echo $line
- return 0
- fi
- done < /etc/ccw.conf
- return 1
-}
-
-print_s390() {
- local _netif
- local SUBCHANNELS
- local OPTIONS
- local NETTYPE
- local CONFIG_LINE
- local i
- local channel
- local OLD_IFS
-
- _netif="$1"
- # if we find ccw channel, then use those, instead of
- # of the MAC
- SUBCHANNELS=$({
- for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
- [ -e $i ] || continue
- channel=$(readlink -f $i)
- echo -n "${channel##*/},"
- done
- })
- [ -n "$SUBCHANNELS" ] || return 1
-
- SUBCHANNELS=${SUBCHANNELS%,}
- echo "SUBCHANNELS=\"${SUBCHANNELS}\""
-
- CONFIG_LINE=$(get_config_line_by_subchannel $SUBCHANNELS)
- [ $? -ne 0 -o -z "$CONFIG_LINE" ] && return 0
-
- OLD_IFS=$IFS
- IFS=","
- set -- $CONFIG_LINE
- IFS=$OLD_IFS
- NETTYPE=$1
- shift
- SUBCHANNELS="$1"
- OPTIONS=""
- shift
- while [ $# -gt 0 ]; do
- case $1 in
- *=*) OPTIONS="$OPTIONS $1";;
- esac
- shift
- done
- OPTIONS=${OPTIONS## }
- echo "NETTYPE=\"${NETTYPE}\""
- echo "OPTIONS=\"${OPTIONS}\""
- return 0
-}
-
-for netup in /tmp/net.*.did-setup ; do
- [ -f $netup ] || continue
-
- netif=${netup%%.did-setup}
- netif=${netif##*/net.}
- strstr "$netif" ":*:*:*:*:" && continue
- [ -e /tmp/ifcfg/ifcfg-$netif ] && continue
- unset bridge
- unset bond
- unset bondslaves
- unset bondname
- unset bondoptions
- unset uuid
- unset ip
- unset gw
- unset mtu
- unset mask
- unset macaddr
- unset slave
- unset ethname
- [ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
-
- uuid=$(cat /proc/sys/kernel/random/uuid)
- if [ "$netif" = "$bridgename" ]; then
- bridge=yes
- elif [ "$netif" = "$bondname" ]; then
- # $netif can't be bridge and bond at the same time
- bond=yes
- fi
- if [ "$netif" = "$vlanname" ]; then
- vlan=yes
- fi
- [ -e /sys/class/net/$netif/address ] && \
- cat /sys/class/net/$netif/address > /tmp/net.$netif.hwaddr
- {
- echo "# Generated by dracut initrd"
- echo "DEVICE=\"$netif\""
- echo "ONBOOT=yes"
- echo "NETBOOT=yes"
- echo "UUID=\"$uuid\""
- if [ -f /tmp/dhclient.$netif.lease ]; then
- [ -f /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
- strstr "$ip" '*:*:*' && echo "IPV6INIT=yes"
- if [ -f /tmp/net.$netif.has_ibft_config ]; then
- echo "BOOTPROTO=ibft"
- else
- echo "BOOTPROTO=dhcp"
- fi
- cp /tmp/dhclient.$netif.lease /tmp/ifcfg-leases/dhclient-$uuid-$netif.lease
- else
- # If we've booted with static ip= lines, the override file is there
- [ -e /tmp/net.$netif.override ] && . /tmp/net.$netif.override
- if strstr "$ip" '*:*:*'; then
- echo "IPV6INIT=yes"
- echo "IPV6_AUTOCONF=no"
- echo "IPV6ADDR=\"$ip/$mask\""
- else
- if [ -f /tmp/net.$netif.has_ibft_config ]; then
- echo "BOOTPROTO=ibft"
- else
- echo "BOOTPROTO=none"
- echo "IPADDR=\"$ip\""
- if strstr "$mask" "."; then
- echo "NETMASK=\"$mask\""
- else
- echo "PREFIX=\"$mask\""
- fi
- fi
- fi
- if strstr "$gw" '*:*:*'; then
- echo "IPV6_DEFAULTGW=\"$gw\""
- elif [ -n "$gw" ]; then
- echo "GATEWAY=\"$gw\""
- fi
- fi
- [ -n "$mtu" ] && echo "MTU=\"$mtu\""
- } > /tmp/ifcfg/ifcfg-$netif
-
- # bridge needs different things written to ifcfg
- if [ -z "$bridge" ] && [ -z "$bond" ] && [ -z "$vlan" ]; then
- # standard interface
- {
- [ -n "$macaddr" ] && echo "MACADDR=\"$macaddr\""
- if ! print_s390 $netif; then
- [ -n "$macaddr" ] || echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
- fi
- echo "TYPE=Ethernet"
- echo "NAME=\"$netif\""
- [ -n "$mtu" ] && echo "MTU=\"$mtu\""
- } >> /tmp/ifcfg/ifcfg-$netif
- fi
-
- if [ -n "$vlan" ] ; then
- {
- echo "TYPE=Vlan"
- echo "NAME=\"$netif\""
- echo "VLAN=yes"
- echo "PHYSDEV=\"$phydevice\""
- } >> /tmp/ifcfg/ifcfg-$netif
- fi
-
- if [ -n "$bond" ] ; then
- # bond interface
- {
- # This variable is an indicator of a bond interface for initscripts
- echo "BONDING_OPTS=\"$bondoptions\""
- echo "NAME=\"$netif\""
- echo "TYPE=Bond"
- } >> /tmp/ifcfg/ifcfg-$netif
-
- for slave in $bondslaves ; do
- # write separate ifcfg file for the raw eth interface
- {
- echo "# Generated by dracut initrd"
- echo "DEVICE=\"$slave\""
- echo "TYPE=Ethernet"
- echo "ONBOOT=yes"
- echo "NETBOOT=yes"
- echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
- echo "SLAVE=yes"
- echo "MASTER=\"$netif\""
- echo "NAME=\"$slave\""
- } >> /tmp/ifcfg/ifcfg-$slave
- done
- fi
-
- if [ -n "$bridge" ] ; then
- # bridge
- {
- echo "TYPE=Bridge"
- echo "NAME=\"$netif\""
- } >> /tmp/ifcfg/ifcfg-$netif
- if [ "$ethname" = "$bondname" ] ; then
- {
- echo "# Generated by dracut initrd"
- echo "DEVICE=\"$bondname\""
- echo "ONBOOT=yes"
- echo "NETBOOT=yes"
- # This variable is an indicator of a bond interface for initscripts
- echo "BONDING_OPTS=\"$bondoptions\""
- echo "BRIDGE=\"$netif\""
- echo "NAME=\"$bondname\""
- } >> /tmp/ifcfg/ifcfg-$bondname
- for slave in $bondslaves ; do
- # write separate ifcfg file for the raw eth interface
- {
- echo "# Generated by dracut initrd"
- echo "DEVICE=\"$slave\""
- echo "TYPE=Ethernet"
- echo "ONBOOT=yes"
- echo "NETBOOT=yes"
- echo "HWADDR=\"$(cat /sys/class/net/$slave/address)\""
- echo "SLAVE=yes"
- echo "MASTER=\"$bondname\""
- echo "NAME=\"$slave\""
- } >> /tmp/ifcfg/ifcfg-$slave
- done
- else
- # write separate ifcfg file for the raw eth interface
- {
- echo "# Generated by dracut initrd"
- echo "DEVICE=\"$ethname\""
- echo "TYPE=Ethernet"
- echo "ONBOOT=yes"
- echo "NETBOOT=yes"
- echo "HWADDR=\"$(cat /sys/class/net/$ethname/address)\""
- echo "BRIDGE=\"$netif\""
- echo "NAME=\"$ethname\""
- } >> /tmp/ifcfg/ifcfg-$ethname
- fi
- fi
- i=1
- for ns in $(getargs nameserver); do
- echo "DNS${i}=\"${ns}\"" >> /tmp/ifcfg/ifcfg-$netif
- i=$((i+1))
- done
-done
-
-# Pass network opts
-mkdir -m 0755 -p /run/initramfs/state/etc/sysconfig/network-scripts
-mkdir -m 0755 -p /run/initramfs/state/var/lib/dhclient
-echo "files /etc/sysconfig/network-scripts" >> /run/initramfs/rwtab
-echo "files /var/lib/dhclient" >> /run/initramfs/rwtab
-{
- cp /tmp/net.* /run/initramfs/
- cp /tmp/net.$netif.resolv.conf /run/initramfs/state/etc/resolv.conf
- copytree /tmp/ifcfg /run/initramfs/state/etc/sysconfig/network-scripts
- cp /tmp/ifcfg-leases/* /run/initramfs/state/var/lib/dhclient
-} > /dev/null 2>&1
--
1.8.1.4