verification abnd disable wifi
This commit is contained in:
Vendored
+40
-3
@@ -194,6 +194,28 @@ mkdir -p "$(dirname "$LOG_FILE")"
|
||||
# 1. Verificar Persistência Existente
|
||||
if is_persistence_configured; then
|
||||
log "Configuração já persistida no sistema. A saltar configuração de 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
|
||||
|
||||
monitor_network_task &
|
||||
exit 0
|
||||
fi
|
||||
@@ -261,13 +283,28 @@ log "A configurar sistema com MAC: $TARGET_MAC"
|
||||
|
||||
if set_mac "$IFACE" "$TARGET_MAC"; then
|
||||
setup_udev_persistence "$IFACE" "$TARGET_MAC"
|
||||
# Check if disable_wifi is already running
|
||||
|
||||
# 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
|
||||
#configure_static_ip
|
||||
disable_wifi &
|
||||
else
|
||||
echo "$(date): disable_wifi is already running" | tee -a /var/log/set_mac.log
|
||||
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"
|
||||
|
||||
Reference in New Issue
Block a user