From c82e4c46d1605556185f01264946980be10c9268 Mon Sep 17 00:00:00 2001 From: Tiago Date: Sun, 15 Feb 2026 12:06:47 +0000 Subject: [PATCH] Update debian/set_mac_wifi.sh --- debian/set_mac_wifi.sh | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/debian/set_mac_wifi.sh b/debian/set_mac_wifi.sh index 51fb22d..3485355 100644 --- a/debian/set_mac_wifi.sh +++ b/debian/set_mac_wifi.sh @@ -196,32 +196,32 @@ if [ -n "$1" ]; then TARGET_MAC="$1" log "MAC definido via argumento: $TARGET_MAC" else - # Verificar se é boot (não interativo e sem /dev/tty disponível) + # Verificar se é boot (não interativo e sem /dev/tty disponível) 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}" exit 0 else - # Pergunta ao utilizador se quer gerar um MAC automaticamente - if ask_confirmation "Deseja gerar um novo MAC único automaticamente?" "y"; then - TARGET_MAC=$(generate_unique_mac) - log "MAC gerado automaticamente: $TARGET_MAC" + # Modo interativo ou via curl: Perguntar ao utilizador o que fazer + if ask_confirmation "Deseja configurar um novo MAC para a interface eth0?" "y"; then + if ask_confirmation "Deseja gerar um novo MAC único automaticamente?" "y"; then + TARGET_MAC=$(generate_unique_mac) + log "MAC gerado automaticamente: $TARGET_MAC" + else + # Pergunta para introduzir MAC manualmente + while true; do + read -p "Introduza o MAC (formato XX:XX:XX:XX:XX:XX): " TARGET_MAC < /dev/tty + if [[ "$TARGET_MAC" =~ ^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$ ]]; then + break + else + echo "Formato de MAC inválido. Por favor, introduza no formato XX:XX:XX:XX:XX:XX." + fi + done + fi else - # Pergunta para introduzir MAC manualmente - while true; do - read -p "Introduza o MAC (formato XX:XX:XX:XX:XX:XX): " TARGET_MAC < /dev/tty - if [[ "$TARGET_MAC" =~ ^([0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}$ ]]; then - break - else - echo "Formato de MAC inválido. Por favor, introduza no formato XX:XX:XX:XX:XX:XX." - fi - done + log "${YELLOW}Configuração de MAC cancelada pelo utilizador${NC}" + exit 0 fi - else - # Modo não interativo (boot/curl) sem argumentos: Gerar automático - log "Execução não interativa. A gerar MAC único..." - TARGET_MAC=$(generate_unique_mac) - log "MAC gerado: $TARGET_MAC" fi fi