From 76d749c2707b3756a67fdfca67babbd321d7920a Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 27 May 2014 13:04:44 -0400 Subject: [PATCH] defect 4091 --- xCAT/postscripts/hardeths | 29 +++++++++++++++++++++++------ xCAT/postscripts/updatenetwork | 3 ++- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/xCAT/postscripts/hardeths b/xCAT/postscripts/hardeths index 68e963c22..b29e2953c 100755 --- a/xCAT/postscripts/hardeths +++ b/xCAT/postscripts/hardeths @@ -1,4 +1,4 @@ -#!/bin/sh +PREFIXMASK#!/bin/sh # pmatch determines if 1st argument string is matched by 2nd argument pattern pmatch () @@ -9,6 +9,18 @@ pmatch () return 1 # non-zero return code means string not matched by pattern } +# converts netmask CIDR fromat to x.x.x.x mask value +maskfromprefix () +{ + prefixlen=$1 + maskval=$((0xffffffff>>(32-prefixlen)<<(32-prefixlen))) + mask1=$((maskval >> 24)) + mask2=$((maskval >> 16 & 0xff)) + mask3=$((maskval >> 8 & 0xff)) + mask4=$((maskval & 0xff)) + echo $mask1.$mask2.$mask3.$mask4 + NETMASK=$mask1.$mask2.$mask3.$mask4 +} network_ipv4calc () { @@ -56,9 +68,12 @@ else echo "GATEWAY=$defgw" >> /etc/sysconfig/network fi fi -for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep -v -- --|grep -v lo`; do - IPADDR=`ifconfig $nic |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}'` - NETMASK=`ifconfig $nic |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'` +for nic in `ip link |grep "BROADCAST" |awk '{print $2}' | sed s/://`; do + IPADDRMASK=`ip addr show dev $nic | grep inet | grep -v inet6 | awk '{print $2}' | head -n 1` + IPADDR=`echo $IPADDRMASK | awk -F'/' '{print $1}'` + PREFIXMASK=`echo $IPADDRMASK | awk -F'/' '{print $2}'` + # converts to x.x.x.x mask value + maskfromprefix $PREFIXMASK if ( pmatch $OSVER "ubuntu*" ) then NETWORK=`network_ipv4calc $IPADDR $NETMASK` @@ -69,7 +84,7 @@ for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep else gateway_line="" fi - + # add info to interfaces file on ubuntu, TBD does unbuntu change to systemd, this will not exist cat >>/etc/network/interfaces <