From eeb77fe2cd3232abd96a1bdf1bbcfcd04053ffff Mon Sep 17 00:00:00 2001 From: Ani Sinha Date: Tue, 10 Oct 2023 11:50:30 +0530 Subject: [PATCH 3/3] Changes for adding keyfile support in RHEL specific script RH-Author: Ani Sinha RH-MergeRequest: 13: hv/hv_kvp_daemon:Support for keyfile based connection profile RH-Jira: RHEL-9901 RH-Acked-by: Jon Maloy RH-Commit: [3/3] 9ce1fe8f1578d41d4265d2c970123c8f71c0c80c Some adjustments to the RHEL specific customization script in order to support Network Manager keyfiles. These changes were tested internally by Red Hat QE. These changes are mostly trivial and are not pushed upstream at this momemnt. Jira: https://issues.redhat.com/browse/RHEL-9901 Signed-off-by: Ani Sinha --- hv_set_ifconfig.sh | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/hv_set_ifconfig.sh b/hv_set_ifconfig.sh index 9c2ee30..93decd6 100644 --- a/hv_set_ifconfig.sh +++ b/hv_set_ifconfig.sh @@ -74,19 +74,23 @@ # call. # +# This is RHEL specific bash script that configures NM keyfiles. +# ifcfg files passed as the first argument to this script remains untouched. +if [ -z "$2" ]; then + echo "No input NM keyfile. Exiting!" + exit 1 +fi -echo "IPV6INIT=yes" >> $1 -echo "PEERDNS=yes" >> $1 -echo "ONBOOT=yes" >> $1 +sed -i '/\[ipv4\]/a ignore-auto-dns=false' $2 +sed -i '/\[connection\]/a autoconnect=true' $2 -#Unlike older sysconfig scripts, NetworkManager expects GATEWAYx=ipaddr for all values of x. -#So the first gateway is GATEWAY0 instead of GATEWAY. Other values should remain unchanged. -#Workaround this by replacing GATEWAY= with GATEWAY0=. -sed -i "s/GATEWAY=/GATEWAY0=/" $1 +filename="${2##*/}" -cp $1 /etc/sysconfig/network-scripts/ +cp $2 /etc/NetworkManager/system-connections/ +chmod 600 /etc/NetworkManager/system-connections/$filename -filename="${1##*/}" -nmcli connection load "/etc/sysconfig/network-scripts/${filename}" -nmcli connection up filename "/etc/sysconfig/network-scripts/${filename}" +nmcli connection load "/etc/NetworkManager/system-connections/${filename}" +nmcli connection up filename "/etc/NetworkManager/system-connections/${filename}" + +exit 0 -- 2.41.0