From 67e5a95878c8fe2b07e7e435ed48df0ab39f3bc5 Mon Sep 17 00:00:00 2001 From: cxhong Date: Wed, 14 Nov 2018 00:41:15 -0500 Subject: [PATCH] Modify configinterface postscripts to handle the MASTER IP address (#5786) * Modify configinterface postscripts to handle the MASTER IP address * Add modification from comments --- xCAT/postscripts/configinterface | 40 +++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/xCAT/postscripts/configinterface b/xCAT/postscripts/configinterface index cc75ea143..1ec8d0d8b 100755 --- a/xCAT/postscripts/configinterface +++ b/xCAT/postscripts/configinterface @@ -9,29 +9,57 @@ fi xcat_intf="/etc/network/interfaces.d/xCAT.intf" -MASTER=$(cat /var/lib/dhcp/dhclient.eth0.leases|sed -n 's/.*cumulus-provision-url.*http:\/\+\([^\/]\+\)\/.*/\1/p'|tail -1) -if [ -z "$MASTER" ]; then - echo "xCAT Master unset! Cannot download interface description" - exit 2 +if [ -f /xcatpost/mypostscript ]; then + MASTER=`grep '^MASTER_IP=' /xcatpost/mypostscript |cut -d= -f2|sed s/\'//g` fi +if [ -z "$MASTER" ]; then + MASTER=$(cat /var/lib/dhcp/dhclient.eth0.leases|sed -n 's/.*cumulus-provision-url.*http:\/\+\([^\/]\+\)\/.*/\1/p'|tail -1) + if [ -z "$MASTER" ]; then + echo "xCAT Master unset! Cannot download interface description" + exit 2 + fi +fi + +#Validate if this IP is reachable +ping $MASTER -c 1 >/dev/null +if [ $? -ne 0 ]; then + echo "ERROR: The xCAT Master ip address $MASTER is not reachable"; + exit 1; +fi + +ORIGFILE=/tmp/xCAT.intf.orig TMPINT=/tmp/xCAT.intf -rm $TMPINT 2>/dev/null +rm -f $TMPINT 2>/dev/null UPDATED=0 +DOWNLOADED=0 for name in $NODE ${GROUP//,/ } default; do curl -s -o $TMPINT -f http://${MASTER}/install/custom/sw_os/cumulus/interface/$name if [ -f $TMPINT ]; then + DOWNLOADED=1 if ! diff $TMPINT $xcat_intf > /dev/null; then - mv $TMPINT $xcat_intf + rm -f $ORIGFILE + cp $xcat_intf $ORIGFILE + mv -f $TMPINT $xcat_intf UPDATED=1 + echo "New interface file downloaded, keep old one to $ORIGFILE"; fi break fi done +if [ $DOWNLOADED -eq 1 ] && [ $UPDATED -eq 0 ]; then + echo "New interface file downloaded to $TMPINT, same as $xcat_intf file"; +fi + +if [ $DOWNLOADED -eq 0 ] && [ -f $xcat_intf ]; then + echo "NO new interface file downloaded, keep same $xcat_intf file"; +fi + if [ ! -f $xcat_intf ]; then UPDATED=1 + echo "NO new interface file downloaded, create a default $xcat_intf file"; echo "#This is sample interface file provided by xCAT" > $xcat_intf echo "# bridge-vlan-aware: set to yes to indicate that the bridge is VLAN-aware. " >> $xcat_intf