2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-31 18:16:39 +00:00

Modify configinterface postscripts to handle the MASTER IP address (#5786)

* Modify configinterface postscripts to handle the MASTER IP address

* Add modification from comments
This commit is contained in:
cxhong 2018-11-14 00:41:15 -05:00 committed by yangsong
parent 28ba3a5cff
commit 67e5a95878

View File

@ -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