From 5d105e204dcbd8b72f6db22be3c3e12fdfbd6cf4 Mon Sep 17 00:00:00 2001 From: "tiago.aica" Date: Sun, 15 Feb 2026 14:03:44 +0000 Subject: [PATCH] minor change --- debian/set_mac_wifi.sh | 44 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/debian/set_mac_wifi.sh b/debian/set_mac_wifi.sh index 632196f..32e3acb 100644 --- a/debian/set_mac_wifi.sh +++ b/debian/set_mac_wifi.sh @@ -247,6 +247,28 @@ else if [ ! -t 0 ] && [ ! -e /dev/tty ]; then # Modo boot: Não fazer nada, assumindo que já foi configurado log "${YELLOW}Modo boot: A saltar configuração de MAC (assumindo que já foi configurado)${NC}" + + # Função auxiliar para verificar se a interface tem IP + has_ip_address() { + local iface="$1" + if ip addr show "$iface" | grep -q "inet "; then + return 0 + else + return 1 + fi + } + + # Verifica se eth0 tem IP antes de desativar Wi-Fi + if has_ip_address "eth0"; then + if ! pgrep -f "disable_wifi" > /dev/null; then + disable_wifi & + else + log "disable_wifi já está em execução." + fi + else + log "eth0 não tem endereço IP. Wi-Fi permanece ativo." + fi + exit 0 else # Modo interativo ou via curl: Perguntar ao utilizador o que fazer @@ -283,28 +305,6 @@ log "A configurar sistema com MAC: $TARGET_MAC" if set_mac "$IFACE" "$TARGET_MAC"; then setup_udev_persistence "$IFACE" "$TARGET_MAC" - - # Função auxiliar para verificar se a interface tem IP - has_ip_address() { - local iface="$1" - if ip addr show "$iface" | grep -q "inet "; then - return 0 - else - return 1 - fi - } - - # Verifica se eth0 tem IP antes de desativar Wi-Fi - if has_ip_address "eth0"; then - if ! pgrep -f "disable_wifi" > /dev/null; then - disable_wifi & - else - log "disable_wifi já está em execução." - fi - else - log "eth0 não tem endereço IP. Wi-Fi permanece ativo." - fi - else log "Aviso: Falha ao definir MAC em tempo real, mas a tentar criar persistência..." setup_udev_persistence "$IFACE" "$TARGET_MAC"