From a82d207b8d0c067ab6f70acb0dc9e47a6f09d3f8 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 10 May 2012 14:31:05 +0200 Subject: [PATCH] ifcfg/write-ifcfg.sh: add s390 specific configuration options https://bugzilla.redhat.com/show_bug.cgi?id=811521 --- modules.d/45ifcfg/write-ifcfg.sh | 70 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/modules.d/45ifcfg/write-ifcfg.sh b/modules.d/45ifcfg/write-ifcfg.sh index 580fbd4..d1f6fe6 100755 --- a/modules.d/45ifcfg/write-ifcfg.sh +++ b/modules.d/45ifcfg/write-ifcfg.sh @@ -20,6 +20,68 @@ 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 + + _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 + + 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}\"" +} + + for netif in $IFACES ; do # bridge? unset bridge @@ -38,7 +100,6 @@ for netif in $IFACES ; do echo "ONBOOT=yes" echo "NETBOOT=yes" echo "UUID=$uuid" - [ -n "$macaddr" ] && echo "MACADDR=$macaddr" [ -n "$mtu" ] && echo "MTU=$mtu" if [ -f /tmp/net.$netif.lease ]; then strstr "$ip" '*:*:*' && @@ -63,7 +124,12 @@ for netif in $IFACES ; do if [ -z "$bridge" ] && [ -z "$bond" ]; then # standard interface { - echo "HWADDR=$(cat /sys/class/net/$netif/address)" + if [ -n "$macaddr" ]; then + echo "MACADDR=$macaddr" + else + echo "HWADDR=\"$(cat /sys/class/net/$netif/address)\"" + fi + print_s390 $netif echo "TYPE=Ethernet" echo "NAME=\"Boot Disk\"" [ -n "$mtu" ] && echo "MTU=$mtu"