From 7ec38c7be8acf8ba29b41daac365cec59b13286d Mon Sep 17 00:00:00 2001 From: xq2005 Date: Mon, 7 Oct 2013 22:59:22 -0700 Subject: [PATCH] bug 3809: get the dhcp info from lease file --- xCAT/postscripts/configeth | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index d1e1d768e..b29c8f1b5 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -388,21 +388,21 @@ elif [ "$1" = "-s" ];then exit 0 elif [ -f "/etc/debian_version" ];then str_lease_file="/var/lib/dhcp/dhclient."$str_inst_nic".leases" - if [ -e $str_lease_file ];then + if [ -e "$str_lease_file" ];then str_inst_ip=`grep fixed-address $str_lease_file | tail -n 1 | awk '{print $2}' | sed 's/;$//'` str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` str_inst_gateway=`grep routers $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` fi elif [ -f "/etc/SuSE-release" ];then str_lease_file="/var/lib/dhcpcd/dhcpcd-"$str_inst_nic".info" - if [ -e $str_lease_file ];then + if [ -e "$str_lease_file" ];then str_inst_ip=`grep IPADDR $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"` str_inst_mask=`grep NETMASK $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"` str_inst_gateway=`grep GATEWAYS $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"` fi else - str_lease_file=`ls /var/lib/dhclient/*$str_inst_nic*` - if [ -e $str_lease_file ];then + str_lease_file=`ls /var/lib/dhclient/*$str_inst_nic* | grep leases` + if [ -e "$str_lease_file" ];then str_inst_ip=`grep fixed-address $str_lease_file | tail -n 1 | awk '{print $2}' | sed 's/;$//'` str_inst_mask=`grep subnet-mask $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'` str_inst_gateway=`grep routers $str_lease_file | tail -n 1 | awk '{print $3}' | sed 's/;$//'`