bug 3809: get the dhcp info from lease file

This commit is contained in:
xq2005 2013-10-07 22:57:42 -07:00
parent 4116445f88
commit 9c409845ba

View File

@ -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/;$//'`