I have set up an USB wifi stick so that it acts as an access point with WPA enabled (WEP’s just too insecure).
Now, when I remove and then replug the stick (or plug it some time after system boot) the WPA security is lost, and I have to restart hostapd manuallyto regain it.
Is there a way to automatically kill hostapd when the stick is unplugged and relaunch it after the device has come up again? FYI: I’m using the traditional scheme using ifup/ifdown…
On 11/28/2013 06:36 AM, Robidu wrote:
>
> Greetings!
>
> I have set up an USB wifi stick so that it acts as an access point with
> WPA enabled (WEP’s just too insecure).
> Now, when I remove and then replug the stick (or plug it some time after
> system boot) the WPA security is lost, and I have to restart hostapd
> manuallyto regain it.
>
> Is there a way to automatically kill hostapd when the stick is unplugged
> and relaunch it after the device has come up again? FYI: I’m using the
> traditional scheme using ifup/ifdown…
There is no automatic way to do it that I know about. The general assumption is
that some boxes are used for computing, and others are used as access points.
The latter are assumed to always be running some version of hostapd, or the
equivalent.
You could write a script that tests if the wlX device is present. If not and
hostapd is running, then kill it. If the device is present and hostapd is not
running, then start it. Then sleep for some time and loop.
I know that jdmcdaniel3 prefers bash for his scripts, but I prefer perl. The
string handling routines are a lot better.
Hmmm… o.k., thanks for the reply.
So it looks as if I need to do some tinkering with the scripts, then.
Polling to see whether or not an interface is up seems to be a bit unsatisfactory, because it greatly depends on the time interval chosen for checking - you could incur a race condition here. I guess I’m going to dig into the startup/shutdown script for the network interfaces to see if I can find anything that could help implementing this.
The best solution would, of course, be a hook within ifup/ifdown that invokes an auxiliary script in case you need additional measures to be taken when an interface is brought up or taken down.