diff --git a/xCAT-server/share/xcat/install/scripts/post.rhels10 b/xCAT-server/share/xcat/install/scripts/post.rhels10 index 8b6bba514..75e864747 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rhels10 +++ b/xCAT-server/share/xcat/install/scripts/post.rhels10 @@ -6,15 +6,7 @@ [ "$MASTER_IP" ] || export MASTER_IP="#ENV:MASTER_IP#" #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib# -if command -v nmcli >/dev/null 2>&1; then - nmcli -g NAME,STATE con show | \ - awk -F: '$1 != "lo" && $2 == "activated" {print $1}' | \ - while IFS= read -r con_name - do - [ -n "$con_name" ] || continue - nmcli con mod "$con_name" connection.autoconnect yes - done -fi +xcat_enable_active_nm_autoconnect internet_repo_file_list="oracle-linux-ol10.repo uek-ol10.repo Rocky-AppStream.repo Rocky-BaseOS.repo Rocky-Extras.repo rocky.repo rocky-extras.repo CentOS-Base.repo centos.repo centos-addons.repo almalinux-ha.repo almalinux-nfv.repo almalinux-powertools.repo almalinux.repo almalinux-resilientstorage.repo almalinux-rt.repo" diff --git a/xCAT-server/share/xcat/install/scripts/post.rhels8 b/xCAT-server/share/xcat/install/scripts/post.rhels8 index 418557a9d..825d42af2 100644 --- a/xCAT-server/share/xcat/install/scripts/post.rhels8 +++ b/xCAT-server/share/xcat/install/scripts/post.rhels8 @@ -6,22 +6,6 @@ [ "$MASTER_IP" ] || export MASTER_IP="#ENV:MASTER_IP#" #INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/scriptlib# -activate_nm_connections() -{ - nmcli -g NAME,STATE con show | \ - awk -F: '$1 != "lo" && $2 == "activated" {print $1}' | \ - while IFS= read -r con_name - do - [ -n "$con_name" ] || continue - case "$XCATDEBUGMODE" in - "1"|"2") - msgutil_r "$MASTER_IP" "info" "set connection $con_name to be activated on system boot" "/var/log/xcat/xcat.log" - ;; - esac - nmcli con mod "$con_name" connection.autoconnect yes - done -} - activated_ifcfg=0 if compgen -G "/etc/sysconfig/network-scripts/ifcfg-*" >/dev/null 2>&1; then for i in /etc/sysconfig/network-scripts/ifcfg-* @@ -40,11 +24,11 @@ if compgen -G "/etc/sysconfig/network-scripts/ifcfg-*" >/dev/null 2>&1; then fi done - if [ "$activated_ifcfg" -eq 0 ] && command -v nmcli >/dev/null 2>&1; then - activate_nm_connections + if [ "$activated_ifcfg" -eq 0 ]; then + xcat_enable_active_nm_autoconnect 1 fi -elif command -v nmcli >/dev/null 2>&1; then - activate_nm_connections +else + xcat_enable_active_nm_autoconnect 1 fi # List of internal repos to be disabled diff --git a/xCAT-server/share/xcat/install/scripts/scriptlib b/xCAT-server/share/xcat/install/scripts/scriptlib index 3cd7ba10e..ab74bddb6 100644 --- a/xCAT-server/share/xcat/install/scripts/scriptlib +++ b/xCAT-server/share/xcat/install/scripts/scriptlib @@ -43,3 +43,23 @@ declare -F msgutil &>/dev/null || function msgutil { msgutil_r "" "$@" } +declare -F xcat_enable_active_nm_autoconnect &>/dev/null || function xcat_enable_active_nm_autoconnect { + local log_changes="${1:-}" + + command -v nmcli >/dev/null 2>&1 || return 0 + + nmcli -g NAME,STATE con show | \ + awk -F: '$1 != "lo" && $2 == "activated" {print $1}' | \ + while IFS= read -r con_name + do + [ -n "$con_name" ] || continue + if [ -n "$log_changes" ]; then + case "$XCATDEBUGMODE" in + "1"|"2") + msgutil_r "$MASTER_IP" "info" "set connection $con_name to be activated on system boot" "/var/log/xcat/xcat.log" + ;; + esac + fi + nmcli con mod "$con_name" connection.autoconnect yes + done +}