confignics modify -s option
This commit is contained in:
parent
787fb3207c
commit
9390efe04e
@ -106,16 +106,10 @@ function configipv4(){
|
||||
if [ $num_v4num -eq 0 ];then
|
||||
echo "DEVICE=${str_if_name}" > $str_conf_file
|
||||
echo "BOOTPROTO=static" >> $str_conf_file
|
||||
echo "BROADCAST=" >> $str_conf_file
|
||||
echo "ETHTOOL_OPTIONS=" >> $str_conf_file
|
||||
echo "IPADDR=${str_v4ip}" >> $str_conf_file
|
||||
echo "MTU=" >> $str_conf_file
|
||||
echo "NAME=" >> $str_conf_file
|
||||
echo "NETMASK=${str_v4mask}" >> $str_conf_file
|
||||
echo "NETWORK=${str_v4net}" >> $str_conf_file
|
||||
echo "REMOTE_IPADDR=" >> $str_conf_file
|
||||
echo "STARTMODE=onboot" >> $str_conf_file
|
||||
echo "UNIQUE=" >> $str_conf_file
|
||||
echo "USERCONTROL=no" >> $str_conf_file
|
||||
echo "_nm_name=static-0" >> $str_conf_file
|
||||
else
|
||||
@ -148,7 +142,7 @@ function configipv4(){
|
||||
echo "DEVICE=${str_if_name}:${num_v4num}" > $str_conf_file
|
||||
fi
|
||||
|
||||
echo "BOOTPROTO=none" >> $str_conf_file
|
||||
echo "BOOTPROTO=static" >> $str_conf_file
|
||||
echo "NM_CONTROLLED=no" >> $str_conf_file
|
||||
echo "IPADDR=${str_v4ip}" >> $str_conf_file
|
||||
echo "NETMASK=${str_v4mask}" >> $str_conf_file
|
||||
@ -211,7 +205,7 @@ configipv6(){
|
||||
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_if_name}"
|
||||
if [ $num_v4num -eq 0 -a $num_v6num -eq 0 ];then
|
||||
echo "DEVICE=$str_if_name" > $str_conf_file
|
||||
echo "BOOTPROTO=none" >> $str_conf_file
|
||||
echo "BOOTPROTO=static" >> $str_conf_file
|
||||
echo "NM_CONTROLLED=no" >> $str_conf_file
|
||||
echo "ONBOOT=yes" >> $str_conf_file
|
||||
fi
|
||||
@ -378,6 +372,102 @@ if [ "$1" = "-r" ];then
|
||||
delete_nic_config_files $str_nic_name
|
||||
fi
|
||||
exit 0
|
||||
elif [ "$1" = "-s" ];then
|
||||
if [ $# -lt 2 ];then
|
||||
logger -t xcat -p local4.err "configeth: config install nic, but the nic name is missed"
|
||||
echo "configeth on $NODE: config install nic, but the nic name is missed"
|
||||
exit 1
|
||||
fi
|
||||
str_inst_nic=$2
|
||||
str_inst_ip=''
|
||||
str_inst_mask=''
|
||||
str_inst_gateway=''
|
||||
if [ "$str_os_type" = "aix" ];then
|
||||
logger -t xcat -p local4.err "configeth: aix does not support -s flag"
|
||||
echo "configeth on $NODE: aix does not support -s flag"
|
||||
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
|
||||
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
|
||||
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_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
|
||||
fi
|
||||
|
||||
if [ -z "$str_inst_ip" -o -z "$str_inst_mask" ];then
|
||||
logger -t xcat -p local4.err "configeth: config install nic, can not find the information from lease file, return."
|
||||
echo "configeth on $NODE: config install nic, can not find information from dhcp lease file, return."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f "/etc/debian_version" ];then
|
||||
str_conf_file="/etc/sysconfig/network/ifcfg-${str_inst_nic}"
|
||||
echo "auto ${str_inst_nic}" > $str_conf_file
|
||||
echo "iface ${str_inst_nic} inet static" >> $str_conf_file
|
||||
echo " address ${str_inst_ip}" >> $str_conf_file
|
||||
echo " netmask ${str_inst_mask}" >> $str_conf_file
|
||||
if [ -n "$str_inst_gateway" ];then
|
||||
echo " gateway $str_inst_gateway" >> $str_conf_file
|
||||
fi
|
||||
hostname $NODE
|
||||
echo $NODE > /etc/hostname
|
||||
elif [ -f "/etc/SuSE-release" ];then
|
||||
str_conf_file="/etc/network/interfaces.d/${str_inst_nic}"
|
||||
echo "DEVICE=${str_inst_nic}" > $str_conf_file
|
||||
echo "BOOTPROTO=static" >> $str_conf_file
|
||||
echo "IPADDR=${str_inst_ip}" >> $str_conf_file
|
||||
echo "NETMASK=${str_inst_mask}" >> $str_conf_file
|
||||
echo "STARTMODE=onboot" >> $str_conf_file
|
||||
if [ -n "$str_inst_gateway" ];then
|
||||
grep -i "default" /etc/sysconfig/network/routes
|
||||
if [ $? -eq 0 ];then
|
||||
sed -i "s/.*default.*/default ${str_inst_gateway} - -/i" /etc/sysconfig/network/routes
|
||||
else
|
||||
echo "default ${str_inst_gateway} - -" >> /etc/sysconfig/network/routes
|
||||
fi
|
||||
fi
|
||||
|
||||
hostname $NODE
|
||||
echo $NODE > /etc/HOSTNAME
|
||||
else
|
||||
str_conf_file="/etc/sysconfig/network-scripts/ifcfg-${str_inst_nic}"
|
||||
echo "DEVICE=${str_inst_nic}" > $str_conf_file
|
||||
echo "IPADDR=${str_inst_ip}" >> $str_conf_file
|
||||
echo "NETMASK=${str_inst_mask}" >> $str_conf_file
|
||||
echo "BOOTPROTO=static" >> $str_conf_file
|
||||
echo "ONBOOT=yes" >> $str_conf_file
|
||||
if [ -n "$str_inst_gateway" ];then
|
||||
grep -i "GATEWAY" /etc/sysconfig/network
|
||||
if [ $? -eq 0 ];then
|
||||
sed -i "s/.*GATEWAY.*/GATEWAY=${str_inst_gateway}/i" /etc/sysconfig/network
|
||||
else
|
||||
echo "GATEWAY=${str_inst_gateway}" >> /etc/sysconfig/network
|
||||
fi
|
||||
fi
|
||||
hostname $NODE
|
||||
grep -i "HOSTNAME" /etc/sysconfig/network
|
||||
if [ $? -eq 0 ];then
|
||||
sed -i "s/.*HOSTNAME.*/HOSTNAME=${NODE}/i" /etc/sysconfig/network
|
||||
else
|
||||
echo "HOSTNAME=${NODE}" >> /etc/sysconfig/network
|
||||
fi
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#main prcess
|
||||
|
@ -91,6 +91,9 @@ elif [ `echo $str_temp | grep -E "e(n|th)[0-9]+"` ];then
|
||||
str_inst_nic=$str_temp
|
||||
fi
|
||||
|
||||
if [ $bool_cfg_inst_nic -eq 1 ];then
|
||||
configeth -s $str_inst_nic
|
||||
fi
|
||||
|
||||
bool_exit_flag=0
|
||||
#check the required attributes
|
||||
@ -162,7 +165,7 @@ if [ $bool_remove -eq 1 ];then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$str_temp_nic" = "$str_inst_nic" -a $bool_cfg_inst_nic -eq 0 ];then
|
||||
if [ "$str_temp_nic" = "$str_inst_nic" ];then
|
||||
continue
|
||||
fi
|
||||
|
||||
@ -187,7 +190,7 @@ do
|
||||
key=`echo $key | sed 's/^ \+//' | sed 's/ \+$//'`
|
||||
str_nic_type=
|
||||
str_value=$(hashget hash_defined_nics $key)
|
||||
if [ "$key" = "$str_inst_nic" -a $bool_cfg_inst_nic -eq 0 ];then
|
||||
if [ "$key" = "$str_inst_nic" ];then
|
||||
continue
|
||||
fi
|
||||
old_ifs=$IFS
|
||||
|
Loading…
Reference in New Issue
Block a user