Update network_menu.sh

This commit is contained in:
MacRimi 2025-07-20 11:38:54 +02:00 committed by GitHub
parent 6e0824e357
commit 0ca87dc29b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,8 @@
# Advanced network management and troubleshooting tool for Proxmox VE.
# Features include interface detection, bridge management, connectivity testing,
# network diagnostics, configuration backup/restore, and automated repairs.
# Special thanks to @Andres_Eduardo_Rojas_Moya for contributing the persistent
# network naming function and for the original idea.
# Configuration ============================================
REPO_URL="https://raw.githubusercontent.com/MacRimi/ProxMenux/main"
BASE_DIR="/usr/local/share/proxmenux"
@ -727,6 +728,66 @@ guided_configuration_cleanup() {
}
# ==========================================================
setup_persistent_network() {
local LINK_DIR="/etc/systemd/network"
local BACKUP_DIR="/etc/systemd/network/backup-$(date +%Y%m%d-%H%M%S)"
if ! dialog --title "$(translate "Network Interface Setup")" \
--yesno "$(translate "Create persistent network interface names?")" 8 60; then
return 1
fi
show_proxmenux_logo
msg_info "$(translate "Setting up persistent network interfaces")"
sleep 2
# Create directory
mkdir -p "$LINK_DIR"
# Backup existing files
if ls "$LINK_DIR"/*.link >/dev/null 2>&1; then
mkdir -p "$BACKUP_DIR"
cp "$LINK_DIR"/*.link "$BACKUP_DIR"/ 2>/dev/null || true
fi
# Process physical interfaces
local count=0
for iface in $(ls /sys/class/net/ | grep -vE "lo|docker|veth|br-|vmbr|tap|fwpr|fwln|virbr|bond|cilium|zt|wg"); do
if [[ -e "/sys/class/net/$iface/device" ]] || [[ -e "/sys/class/net/$iface/phy80211" ]]; then
local MAC=$(cat /sys/class/net/$iface/address 2>/dev/null)
if [[ "$MAC" =~ ^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$ ]]; then
local LINK_FILE="$LINK_DIR/10-$iface.link"
cat > "$LINK_FILE" <<EOF
[Match]
MACAddress=$MAC
[Link]
Name=$iface
EOF
chmod 644 "$LINK_FILE"
((count++))
fi
fi
done
if [[ $count -gt 0 ]]; then
msg_ok "$(translate "Created persistent names for") $count $(translate "interfaces")"
msg_ok "$(translate "Changes will apply after reboot.")"
else
msg_warn "$(translate "No physical interfaces found")"
fi
register_tool "persistent_network" true
echo -e
msg_success "$(translate "Press ENTER to continue...")"
read -r
}
# ==========================================================
@ -922,6 +983,7 @@ declare -a PROXMENUX_SCRIPTS=(
"Advanced Diagnostics||advanced_network_diagnostics"
"Analyze Bridge Configuration||analyze_bridge_configuration"
"Analyze Network Configuration||analyze_network_configuration"
"Setup Persistent Network Names||setup_persistent_network"
"Restart Network Service||restart_network_service"
"Show Network Config File||show_network_config"
"Create Network Backup||create_network_backup_manual"
@ -1002,7 +1064,7 @@ show_menu() {
--backtitle "ProxMenux" \
--title "$(translate "Network Management")" \
--menu "\n$(translate "Select a network management option:"):\n" \
25 78 18 \
26 78 19 \
"${menu_items[@]}" 2>&1 1>&3)
exit_status=$?
exec 3>&-