verification abnd disable wifi
This commit is contained in:
Vendored
+42
-5
@@ -194,6 +194,28 @@ mkdir -p "$(dirname "$LOG_FILE")"
|
|||||||
# 1. Verificar Persistência Existente
|
# 1. Verificar Persistência Existente
|
||||||
if is_persistence_configured; then
|
if is_persistence_configured; then
|
||||||
log "Configuração já persistida no sistema. A saltar configuração de MAC."
|
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 &
|
monitor_network_task &
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
@@ -261,13 +283,28 @@ log "A configurar sistema com MAC: $TARGET_MAC"
|
|||||||
|
|
||||||
if set_mac "$IFACE" "$TARGET_MAC"; then
|
if set_mac "$IFACE" "$TARGET_MAC"; then
|
||||||
setup_udev_persistence "$IFACE" "$TARGET_MAC"
|
setup_udev_persistence "$IFACE" "$TARGET_MAC"
|
||||||
# Check if disable_wifi is already running
|
|
||||||
if ! pgrep -f "disable_wifi" > /dev/null; then
|
# Função auxiliar para verificar se a interface tem IP
|
||||||
#configure_static_ip
|
has_ip_address() {
|
||||||
disable_wifi &
|
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
|
else
|
||||||
echo "$(date): disable_wifi is already running" | tee -a /var/log/set_mac.log
|
log "eth0 não tem endereço IP. Wi-Fi permanece ativo."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
log "Aviso: Falha ao definir MAC em tempo real, mas a tentar criar persistência..."
|
log "Aviso: Falha ao definir MAC em tempo real, mas a tentar criar persistência..."
|
||||||
setup_udev_persistence "$IFACE" "$TARGET_MAC"
|
setup_udev_persistence "$IFACE" "$TARGET_MAC"
|
||||||
|
|||||||
Reference in New Issue
Block a user