Blame 0054-ifcfg-write-ifcfg.sh-add-s390-specific-configuration.patch

Harald Hoyer 35271e
From a82d207b8d0c067ab6f70acb0dc9e47a6f09d3f8 Mon Sep 17 00:00:00 2001
Harald Hoyer 35271e
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 35271e
Date: Thu, 10 May 2012 14:31:05 +0200
Harald Hoyer 35271e
Subject: [PATCH] ifcfg/write-ifcfg.sh: add s390 specific configuration
Harald Hoyer 35271e
 options
Harald Hoyer 35271e
Harald Hoyer 35271e
https://bugzilla.redhat.com/show_bug.cgi?id=811521
Harald Hoyer 35271e
---
Harald Hoyer 35271e
 modules.d/45ifcfg/write-ifcfg.sh |   70 ++++++++++++++++++++++++++++++++++++--
Harald Hoyer 35271e
 1 file changed, 68 insertions(+), 2 deletions(-)
Harald Hoyer 35271e
Harald Hoyer 35271e
diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 35271e
index 580fbd4..d1f6fe6 100755
Harald Hoyer 35271e
--- a/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 35271e
+++ b/modules.d/45ifcfg/write-ifcfg.sh
Harald Hoyer 35271e
@@ -20,6 +20,68 @@ fi
Harald Hoyer 35271e
 mkdir -m 0755 -p /tmp/ifcfg/
Harald Hoyer 35271e
 mkdir -m 0755 -p /tmp/ifcfg-leases/
Harald Hoyer 35271e
 
Harald Hoyer 35271e
+get_config_line_by_subchannel()
Harald Hoyer 35271e
+{
Harald Hoyer 35271e
+    local CHANNEL
Harald Hoyer 35271e
+    local line
Harald Hoyer 35271e
+
Harald Hoyer 35271e
+    CHANNELS="$1"
Harald Hoyer 35271e
+    while read line; do
Harald Hoyer 35271e
+        if strstr "$line" "$CHANNELS"; then
Harald Hoyer 35271e
+            echo $line
Harald Hoyer 35271e
+            return 0
Harald Hoyer 35271e
+        fi
Harald Hoyer 35271e
+    done < /etc/ccw.conf
Harald Hoyer 35271e
+    return 1
Harald Hoyer 35271e
+}
Harald Hoyer 35271e
+
Harald Hoyer 35271e
+print_s390() {
Harald Hoyer 35271e
+    local _netif
Harald Hoyer 35271e
+    local SUBCHANNELS
Harald Hoyer 35271e
+    local OPTIONS
Harald Hoyer 35271e
+    local NETTYPE
Harald Hoyer 35271e
+    local CONFIG_LINE
Harald Hoyer 35271e
+    local i
Harald Hoyer 35271e
+    local channel
Harald Hoyer 35271e
+
Harald Hoyer 35271e
+    _netif="$1"
Harald Hoyer 35271e
+    # if we find ccw channel, then use those, instead of
Harald Hoyer 35271e
+    # of the MAC
Harald Hoyer 35271e
+    SUBCHANNELS=$({
Harald Hoyer 35271e
+        for i in /sys/class/net/$_netif/device/cdev[0-9]*; do
Harald Hoyer 35271e
+            [ -e $i ] || continue
Harald Hoyer 35271e
+            channel=$(readlink -f $i)
Harald Hoyer 35271e
+            echo -n "${channel##*/},"
Harald Hoyer 35271e
+        done
Harald Hoyer 35271e
+    })
Harald Hoyer 35271e
+    [ -n "$SUBCHANNELS" ] || return 1
Harald Hoyer 35271e
+
Harald Hoyer 35271e
+    SUBCHANNELS=${SUBCHANNELS%,}
Harald Hoyer 35271e
+    echo "SUBCHANNELS=\"${SUBCHANNELS}\""
Harald Hoyer 35271e
+    CONFIG_LINE=$(get_config_line_by_subchannel $SUBCHANNELS)
Harald Hoyer 35271e
+
Harald Hoyer 35271e
+    [ $? -ne 0 -o -z "$CONFIG_LINE" ] && return
Harald Hoyer 35271e
+
Harald Hoyer 35271e
+    IFS=","
Harald Hoyer 35271e
+    set $CONFIG_LINE
Harald Hoyer 35271e
+    IFS="$OLD_IFS"
Harald Hoyer 35271e
+    NETTYPE=$1
Harald Hoyer 35271e
+    shift
Harald Hoyer 35271e
+    SUBCHANNELS="$1"
Harald Hoyer 35271e
+    OPTIONS=""
Harald Hoyer 35271e
+    shift
Harald Hoyer 35271e
+    while [ $# -gt 0 ]; do
Harald Hoyer 35271e
+        case $1 in
Harald Hoyer 35271e
+            *=*) OPTIONS="$OPTIONS $1";;
Harald Hoyer 35271e
+        esac
Harald Hoyer 35271e
+        shift
Harald Hoyer 35271e
+    done
Harald Hoyer 35271e
+    OPTIONS=${OPTIONS## }
Harald Hoyer 35271e
+    echo "NETTYPE=\"${NETTYPE}\""
Harald Hoyer 35271e
+    echo "OPTIONS=\"${OPTIONS}\""
Harald Hoyer 35271e
+}
Harald Hoyer 35271e
+
Harald Hoyer 35271e
+
Harald Hoyer 35271e
 for netif in $IFACES ; do
Harald Hoyer 35271e
     # bridge?
Harald Hoyer 35271e
     unset bridge
Harald Hoyer 35271e
@@ -38,7 +100,6 @@ for netif in $IFACES ; do
Harald Hoyer 35271e
         echo "ONBOOT=yes"
Harald Hoyer 35271e
         echo "NETBOOT=yes"
Harald Hoyer 35271e
         echo "UUID=$uuid"
Harald Hoyer 35271e
-        [ -n "$macaddr" ] && echo "MACADDR=$macaddr"
Harald Hoyer 35271e
         [ -n "$mtu" ] && echo "MTU=$mtu"
Harald Hoyer 35271e
         if [ -f /tmp/net.$netif.lease ]; then
Harald Hoyer 35271e
             strstr "$ip" '*:*:*' &&
Harald Hoyer 35271e
@@ -63,7 +124,12 @@ for netif in $IFACES ; do
Harald Hoyer 35271e
     if [ -z "$bridge" ] && [ -z "$bond" ]; then
Harald Hoyer 35271e
         # standard interface
Harald Hoyer 35271e
         {
Harald Hoyer 35271e
-            echo "HWADDR=$(cat /sys/class/net/$netif/address)"
Harald Hoyer 35271e
+            if [ -n "$macaddr" ]; then
Harald Hoyer 35271e
+                echo "MACADDR=$macaddr"
Harald Hoyer 35271e
+            else
Harald Hoyer 35271e
+                echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\""
Harald Hoyer 35271e
+            fi
Harald Hoyer 35271e
+            print_s390 $netif
Harald Hoyer 35271e
             echo "TYPE=Ethernet"
Harald Hoyer 35271e
             echo "NAME=\"Boot Disk\""
Harald Hoyer 35271e
             [ -n "$mtu" ] && echo "MTU=$mtu"