Update debian/set_mac_wifi.sh
This commit is contained in:
Vendored
+19
-19
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user