readded disable wifi
This commit is contained in:
Vendored
+32
@@ -13,6 +13,31 @@ log() {
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S'): $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
# Function to disable Wi-Fi
|
||||
disable_wifi() {
|
||||
# Create log directory if it doesn't exist
|
||||
mkdir -p /var/log
|
||||
|
||||
# Wait for 1 minute (60 seconds) before disabling Wi-Fi
|
||||
echo "$(date): Waiting 60 seconds before checking eth0 IP and disabling Wi-Fi..." | tee -a /var/log/set_mac.log
|
||||
sleep 60
|
||||
|
||||
# Check if eth0 has an IP address before disabling Wi-Fi
|
||||
if has_ip_address "eth0"; then
|
||||
if ip link show "wlan0" &> /dev/null; then
|
||||
if ip link set "wlan0" down; then
|
||||
echo "$(date): Wi-Fi (wlan0) disabled successfully (eth0 has IP)" | tee -a /var/log/set_mac.log
|
||||
else
|
||||
echo "$(date): Failed to disable Wi-Fi (wlan0)" | tee -a /var/log/set_mac.log
|
||||
fi
|
||||
else
|
||||
echo "$(date): wlan0 interface not found (Wi-Fi already disabled?)" | tee -a /var/log/set_mac.log
|
||||
fi
|
||||
else
|
||||
echo "$(date): eth0 does not have an IP address. Wi-Fi remains active." | tee -a /var/log/set_mac.log
|
||||
fi
|
||||
}
|
||||
|
||||
# Função para perguntar confirmação ao utilizador
|
||||
ask_confirmation() {
|
||||
local message="$1"
|
||||
@@ -236,6 +261,13 @@ 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
|
||||
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
|
||||
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