Update debian/set_mac_wifi.sh

This commit is contained in:
2026-02-15 12:06:47 +00:00
parent 02bf6c1026
commit c82e4c46d1
+19 -19
View File
@@ -196,32 +196,32 @@ if [ -n "$1" ]; then
TARGET_MAC="$1" TARGET_MAC="$1"
log "MAC definido via argumento: $TARGET_MAC" log "MAC definido via argumento: $TARGET_MAC"
else 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 if [ ! -t 0 ] && [ ! -e /dev/tty ]; then
# Modo boot: Não fazer nada, assumindo que já foi configurado # 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}" log "${YELLOW}Modo boot: A saltar configuração de MAC (assumindo que já foi configurado)${NC}"
exit 0 exit 0
else else
# Pergunta ao utilizador se quer gerar um MAC automaticamente # Modo interativo ou via curl: Perguntar ao utilizador o que fazer
if ask_confirmation "Deseja gerar um novo MAC único automaticamente?" "y"; then if ask_confirmation "Deseja configurar um novo MAC para a interface eth0?" "y"; then
TARGET_MAC=$(generate_unique_mac) if ask_confirmation "Deseja gerar um novo MAC único automaticamente?" "y"; then
log "MAC gerado automaticamente: $TARGET_MAC" 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 else
# Pergunta para introduzir MAC manualmente log "${YELLOW}Configuração de MAC cancelada pelo utilizador${NC}"
while true; do exit 0
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 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
fi fi