Skip to content

Instantly share code, notes, and snippets.

@hyperair
Created October 22, 2013 09:58
Show Gist options
  • Select an option

  • Save hyperair/7098053 to your computer and use it in GitHub Desktop.

Select an option

Save hyperair/7098053 to your computer and use it in GitHub Desktop.
A simple watchdog daemon that checks for wpa_supplicant attempting to reestablish the connection and temporarily removes wlan0 from the bridge it is connected to.
#!/bin/sh
# wlan-watchdog -- a simple watchdog daemon that checks for wpa_supplicant
# attempting to reestablish the connection and temporarily removes wlan0 from
# the bridge.
#
# Copyright 2013 Chow Loong Jin <hyperair@debian.org>
# Licensed under WTFPL
#
# This is a workaround for a weird bug in iwl4965 where wpa_supplicant is not
# able to complete authentication when attached to a bridge, with error messages
# that look like:
# wpa_supplicant: CTRL-EVENT-DISCONNECTED bssid=aa:bb:cc:dd:ee:ff reason=2
while true; do
while wpa_cli status verbose | grep -q wpa_state=COMPLETED; do
sleep 1
done
echo "wlan0 is trying to connect, remove from bridge..."
brctl delif br0 wlan0
until wpa_cli status verbose | grep -q wpa_state=COMPLETED; do
sleep 1
done
echo "wlan0 is connected! Add back to bridge.."
brctl addif br0 wlan0
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment