From a9d48dc2517d2760049220c3b9c02a3cef362d92 Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Fri, 27 Jul 2018 14:20:00 -0700 Subject: [PATCH 1/2] hardeths: only add GATEWAY in /etc/sysconfig/network if it's not already there. Replace it otherwise. --- xCAT/postscripts/hardeths | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/hardeths b/xCAT/postscripts/hardeths index 46765f673..f5d13cde8 100755 --- a/xCAT/postscripts/hardeths +++ b/xCAT/postscripts/hardeths @@ -73,7 +73,9 @@ else sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network fi if [ ! -z "$defgw" ]; then - echo "GATEWAY=$defgw" >> /etc/sysconfig/network + grep -qw GATEWAY /etc/sysconfig/network && \ + sed -i "s/^GATEWAY.*/GATEWAY=$defgw/" /etc/sysconfig/network || \ + echo "GATEWAY=$defgw" >> /etc/sysconfig/network fi fi From e37b462c42edaba61831724a7b668d87eca642ca Mon Sep 17 00:00:00 2001 From: Kilian Cavalotti Date: Fri, 27 Jul 2018 15:29:19 -0700 Subject: [PATCH 2/2] hardeths: when multiple default routes are defined, only select one --- xCAT/postscripts/hardeths | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xCAT/postscripts/hardeths b/xCAT/postscripts/hardeths index f5d13cde8..729d22c27 100755 --- a/xCAT/postscripts/hardeths +++ b/xCAT/postscripts/hardeths @@ -50,7 +50,7 @@ if [ -f /etc/os-release ] && (cat /etc/os-release |grep -i '^NAME=[ "]*Cumulus OSVER="cumulus" fi -defgw=`ip route | grep default | awk '{print $3}'` +defgw=`ip route | grep default | awk '{print $3}' | head -n1` if ( pmatch $OSVER "ubuntu*" ) || (pmatch $OSVER "cumulus") then echo `hostname` >/etc/hostname