2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-04 20:17:55 +00:00

refactor(netboot): share NetworkManager autoconnect setup

This commit is contained in:
Vinícius Ferrão
2026-08-30 21:53:29 -03:00
parent a5ad2f7b26
commit 7032b75c94
3 changed files with 25 additions and 29 deletions
@@ -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"
@@ -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
@@ -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
}