Hostapd: execute a command when there is new connection established


I need to start an arbitrary daemon when at least one WiFi network connection exists (from clients). And stop an arbitrary daemon when there is no more connections to this AP. How to do it efficiently?
For now I consider polling the results of hostapd_cli all_sta, but it seems odd. I'm sure there must be some system event which can be hooked.

Best Answer

  • As @beemaster said run this:

    hostapd_cli -a '/'

    With the script:

    if [[ $2 == "AP-STA-CONNECTED" ]]
      echo "someone has connected with mac id $3 on $1"
    if [[ $2 == "AP-STA-DISCONNECTED" ]]
      echo "someone has disconnected with mac id $3 on $1"
  • Related Question