Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configib: fix/clean up el9 support #7459

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 91 additions & 77 deletions xCAT/postscripts/configib
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ then
exit
fi

if [ $OS_name != 'ubuntu' ]; then
if [[ $OS_name != 'ubuntu' ]] && [[ ! "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
if [ $OS_name == 'suse' ]
then
dir="/etc/sysconfig/network"
Expand All @@ -192,7 +192,7 @@ then
rm -f $dir/ifcfg-$nic 2>&1 1>/dev/null
done

else
elif [ $OS_name == 'ubuntu' ]; then
interfaces="/etc/network/interfaces"

for tmp in `sed -n "/auto ib/=" ${interfaces}`
Expand Down Expand Up @@ -439,15 +439,11 @@ IPADDR=$nicip" > $dir/ifcfg-$nic
name="${array_extra_param_names[$i]}"
value="${array_extra_param_values[$i]}"
echo " $i: name=$name value=$value"
if [[ "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
nmcli con modify $con_name $name $value
grep -i "${name}" $dir/ifcfg-$nic
if [ $? -eq 0 ];then
sed -i "s/.*${name}.*/${name}=${value}/i" >> $dir/ifcfg-$nic
else
grep -i "${name}" $dir/ifcfg-$nic
if [ $? -eq 0 ];then
sed -i "s/.*${name}.*/${name}=${value}/i" >> $dir/ifcfg-$nic
else
echo "${name}=${value}" >> $dir/ifcfg-$nic
fi
echo "${name}=${value}" >> $dir/ifcfg-$nic
fi
i=$((i+1))
done
Expand Down Expand Up @@ -475,15 +471,11 @@ IPADDR_$ipindex=$nicip" >> $dir/ifcfg-$nic
name="${array_extra_param_names[$i]}"
value="${array_extra_param_values[$i]}"
echo " $i: name=$name value=$value"
if [[ "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
nmcli con modify $con_name $name $value
grep -i "${name}" $dir/ifcfg-$nic
if [ $? -eq 0 ];then
sed -i "s/.*${name}.*/${name}=${value}/i" >> $dir/ifcfg-$nic
else
grep -i "${name}" $dir/ifcfg-$nic
if [ $? -eq 0 ];then
sed -i "s/.*${name}.*/${name}=${value}/i" >> $dir/ifcfg-$nic
else
echo "${name}=${value}" >> $dir/ifcfg-$nic
fi
echo "${name}=${value}" >> $dir/ifcfg-$nic
fi
i=$((i+1))
done
Expand All @@ -493,39 +485,50 @@ IPADDR_$ipindex=$nicip" >> $dir/ifcfg-$nic
# First ip address
if [ $ipindex -eq 1 ]
then
nmcontrol=""
devtype=""
if [ $nmcli_used -eq 0 ]; then
nmcontrol="NM_CONTROLLED=no"
if [[ "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
# ipv6
if echo $nicip | grep : 2>&1 1>/dev/null
then
nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
else # ipv4
prefix=$(convert_netmask_to_cidr $netmask)
nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip/$prefix
fi
else
devtype="TYPE=InfiniBand"
fi
# Write the info to the ifcfg file
echo "DEVICE=$nic
nmcontrol=""
devtype=""
if [ $nmcli_used -eq 0 ]; then
nmcontrol="NM_CONTROLLED=no"
else
devtype="TYPE=InfiniBand"
fi
# Write the info to the ifcfg file
echo "DEVICE=$nic
$nmcontrol
$devtype
BOOTPROTO=none
ONBOOT=yes
DEFROUTE=no
NAME=$nic
IPADDR=$nicip" > $dir/ifcfg-$nic
# ipv6
if echo $nicip | grep : 2>&1 1>/dev/null
then
echo "PREFIXLEN=$netmask" >> $dir/ifcfg-$nic
else
if [[ "$OSVER" == rhels6* ]]
# ipv6
if echo $nicip | grep : 2>&1 1>/dev/null
then
#get prefix from netmask, this is for IPv4 only
prefix=24
prefix=$(convert_netmask_to_cidr $netmask)
echo "PREFIX=$prefix" >> $dir/ifcfg-$nic
echo "PREFIXLEN=$netmask" >> $dir/ifcfg-$nic
else
echo "NETMASK=$netmask" >> $dir/ifcfg-$nic
if [[ "$OSVER" == rhels6* ]]
then
#get prefix from netmask, this is for IPv4 only
prefix=24
prefix=$(convert_netmask_to_cidr $netmask)
echo "PREFIX=$prefix" >> $dir/ifcfg-$nic
else
echo "NETMASK=$netmask" >> $dir/ifcfg-$nic
fi
fi
if [ -n "$gateway" ]; then
echo "GATEWAY=$gateway" >> $dir/ifcfg-$nic
fi
fi
if [ -n "$gateway" ]; then
echo "GATEWAY=$gateway" >> $dir/ifcfg-$nic
fi


Expand All @@ -549,52 +552,63 @@ IPADDR=$nicip" > $dir/ifcfg-$nic
i=$((i+1))
done
else # not the first ip address
# ipv6
if echo $nicip | grep : 2>&1 1>/dev/null
then
grep "IPV6INIT" $dir/ifcfg-$nic 2>&1 1>/dev/null
# The first ipv6 address
if [ $? -ne 0 ]
if [[ "$OSVER" =~ ^(rhels9|alma9|rocky9) ]]; then
# ipv6
if echo $nicip | grep : 2>&1 1>/dev/null
then
echo "IPV6INIT=yes
IPV6ADDR=$nicip/$netmask" >> $dir/ifcfg-$nic
else
echo "IPV6ADDR_SECONDARIES=$nicip/$netmask" >> $dir/ifcfg-$nic
fi
if [ -n "$gateway" ]; then
echo "IPV6_DEFAULTGW=$gateway" >> $dir/ifcfg-$nic
nmcli con add type infiniband con-name $nic ifname $nic ipv6.method manual ipv6.addresses $nicip
else # ipv4
prefix=$(convert_netmask_to_cidr $netmask)
nmcli con add type infiniband con-name $nic ifname $nic ipv4.method manual ipv4.addresses $nicip/$prefix
fi
else # ipv4 address
if [ $nmcli_used -eq 0 ]; then
cfgfile=$dir"/ifcfg-"$nic":"$ipindex
cfgcontent= "DEVICE=$nic:$ipindex
else
# ipv6
if echo $nicip | grep : 2>&1 1>/dev/null
then
grep "IPV6INIT" $dir/ifcfg-$nic 2>&1 1>/dev/null
# The first ipv6 address
if [ $? -ne 0 ]
then
echo "IPV6INIT=yes
IPV6ADDR=$nicip/$netmask" >> $dir/ifcfg-$nic
else
echo "IPV6ADDR_SECONDARIES=$nicip/$netmask" >> $dir/ifcfg-$nic
fi
if [ -n "$gateway" ]; then
echo "IPV6_DEFAULTGW=$gateway" >> $dir/ifcfg-$nic
fi
else # ipv4 address
if [ $nmcli_used -eq 0 ]; then
cfgfile=$dir"/ifcfg-"$nic":"$ipindex
cfgcontent= "DEVICE=$nic:$ipindex
NM_CONTROLLED=no
BOOTPROTO=none
ONBOOT=yes
NETMASK=$netmask
IPADDR=$nicip"
echo "$cfgcontent" > $cfgfile
else
cfgfile=$dir"/ifcfg-"$nic
cfgcontent="NETMASK$ipindex=$netmask
echo "$cfgcontent" > $cfgfile
else
cfgfile=$dir"/ifcfg-"$nic
cfgcontent="NETMASK$ipindex=$netmask
IPADDR$ipindex=$nicip"
echo "$cfgcontent" >> $cfgfile
fi
if [[ "$OSVER" == rhels6* ]]
then
#get prefix from netmask, this is for IPv4 only
prefix=24
prefix=$(convert_netmask_to_cidr $netmask)
echo "PREFIX=$prefix" >> $cfgfile
else
echo "$nicnetmask" >> $cfgfile
fi

if [ -n "$gateway" ]; then
if [ $nmcli_used -eq 0 ]; then
echo "GATEWAY=$gateway" >> $cfgfile
echo "$cfgcontent" >> $cfgfile
fi
if [[ "$OSVER" == rhels6* ]]
then
#get prefix from netmask, this is for IPv4 only
prefix=24
prefix=$(convert_netmask_to_cidr $netmask)
echo "PREFIX=$prefix" >> $cfgfile
else
echo "GATEWAY$ipindex=$gateway" >> $cfgfile
echo "$nicnetmask" >> $cfgfile
fi

if [ -n "$gateway" ]; then
if [ $nmcli_used -eq 0 ]; then
echo "GATEWAY=$gateway" >> $cfgfile
else
echo "GATEWAY$ipindex=$gateway" >> $cfgfile
fi
fi
fi

Expand Down