[arch-general] Exiting wpa_supplicant
Dear list, I try to write a small shellscript that (dis-)connects me with / from the WLAN of my university. I use wpa_supplicant in combination with the -B switch to establish the connection. After a pause of 10 seconds I pull an IP address by calling dhcpcd. My question (in context of the wlan-disconnect-script): how can I exit wpa_supplicant if it runs in the background ? Up to now it's done by "sudo killall wpa_supplicant" but I guess it's not the best way. Kind regards, Nelson.
On Mon, Oct 22, 2012 at 11:57 AM, Nelson Marambio <nelsonmarambio@gmx.de> wrote:
Dear list,
I try to write a small shellscript that (dis-)connects me with / from the WLAN of my university.
I use wpa_supplicant in combination with the -B switch to establish the connection. After a pause of 10 seconds I pull an IP address by calling dhcpcd.
My question (in context of the wlan-disconnect-script): how can I exit wpa_supplicant if it runs in the background ? Up to now it's done by "sudo killall wpa_supplicant" but I guess it's not the best way.
I suggest "wpa_cli terminate". See the wpa_cli manpage.
Am 22.10.2012 17:57, schrieb Nelson Marambio:
I use wpa_supplicant in combination with the -B switch to establish the connection. After a pause of 10 seconds I pull an IP address by calling dhcpcd.
I can't count the number of reasons why this is a bad idea. I've looked into this topic years ago, and the result is netcfg's net-auto-wireless mode.
On Mon, Oct 22, 2012 at 7:29 PM, Thomas Bächler <thomas@archlinux.org>wrote:
Am 22.10.2012 17:57, schrieb Nelson Marambio:
I use wpa_supplicant in combination with the -B switch to establish the connection. After a pause of 10 seconds I pull an IP address by calling dhcpcd.
I can't count the number of reasons why this is a bad idea.
I've looked into this topic years ago, and the result is netcfg's net-auto-wireless mode.
That's interesting. Why is that a bad idea? I used to do it by hand, waiting for wpa_supplicant to stablish a connection and then running dhcp. Nowadays I just use wicd but I'm interested to understand what could go wrong. -- Rafael Beraldo cabaladada.org
Am 23.10.2012 02:42, schrieb Rafael Beraldo:
That's interesting. Why is that a bad idea? I used to do it by hand, waiting for wpa_supplicant to stablish a connection and then running dhcp.
You wait for 10 seconds. That is way too long. A wireless connection is usually established within 3 seconds. Or not. You wait for 10 seconds. That is way too short. A wireless connection may take 30 or even 60 seconds to establish. A wireless connection may go up and down. It may stay down. Or come back up. You need to react to these changes. Luckily, dhcpcd can partially handle this these days and you can simply start dhcpcd without delay, and it will figure out when to request an IP.
-------- Original-Nachricht --------
Datum: Tue, 23 Oct 2012 09:28:57 +0200 Von: "Thomas Bächler" <thomas@archlinux.org> An: arch-general@archlinux.org Betreff: Re: [arch-general] Exiting wpa_supplicant
Am 23.10.2012 02:42, schrieb Rafael Beraldo:
That's interesting. Why is that a bad idea? I used to do it by hand, waiting for wpa_supplicant to stablish a connection and then running dhcp.
You wait for 10 seconds. That is way too long. A wireless connection is usually established within 3 seconds. Or not.
You wait for 10 seconds. That is way too short. A wireless connection may take 30 or even 60 seconds to establish.
A wireless connection may go up and down. It may stay down. Or come back up. You need to react to these changes.
Luckily, dhcpcd can partially handle this these days and you can simply start dhcpcd without delay, and it will figure out when to request an IP.
Hi, Thomas, the delay of 10 seconds is recommended by the computing centre which maintains the university-wide WLAN. Without the delay dhcpcd returns a timeout. Your reasons against wpa_supplicant are conclusive but neither netcfg nor wicd (which I would prefer) are supported here. Especially the encryption method that I have to configure in wicd is not documented. Kind regards, Nelson.
On Tue, 23 Oct 2012 17:14:09 +0200 nelsonmarambio@gmx.de wrote:
-------- Original-Nachricht --------
Datum: Tue, 23 Oct 2012 09:28:57 +0200 Von: "Thomas Bächler" <thomas@archlinux.org> An: arch-general@archlinux.org Betreff: Re: [arch-general] Exiting wpa_supplicant
Am 23.10.2012 02:42, schrieb Rafael Beraldo:
That's interesting. Why is that a bad idea? I used to do it by hand, waiting for wpa_supplicant to stablish a connection and then running dhcp.
You wait for 10 seconds. That is way too long. A wireless connection is usually established within 3 seconds. Or not.
You wait for 10 seconds. That is way too short. A wireless connection may take 30 or even 60 seconds to establish.
A wireless connection may go up and down. It may stay down. Or come back up. You need to react to these changes.
Luckily, dhcpcd can partially handle this these days and you can simply start dhcpcd without delay, and it will figure out when to request an IP.
Hi, Thomas,
the delay of 10 seconds is recommended by the computing centre which maintains the university-wide WLAN. Without the delay dhcpcd returns a timeout.
Your reasons against wpa_supplicant are conclusive but neither netcfg nor wicd (which I would prefer) are supported here. Especially the encryption method that I have to configure in wicd is not documented.
Could you please elaborate on this? If your authentication scheme can be handled with wpa_supplicant, then it is little to no job to implement it in netcfg... On the flip side, others might benefit from this. Wicd should be equally trivial to use, but I walked away from it long time ago...
Kind regards, Nelson.
-- Leonid Isaev GnuPG key: 0x164B5A6D Fingerprint: C0DF 20D0 C075 C3F1 E1BE 775A A7AE F6CB 164B 5A6D
Am 23.10.2012 17:14, schrieb nelsonmarambio@gmx.de:
the delay of 10 seconds is recommended by the computing centre which maintains the university-wide WLAN. Without the delay dhcpcd returns a timeout.
The delay is stupid. And dhcpcd should not even try to get a lease until the connection is established.
Your reasons against wpa_supplicant are conclusive but neither netcfg nor wicd (which I would prefer) are supported here. Especially the encryption method that I have to configure in wicd is not documented.
Everything that is supported by wpa_supplicant is supported by netcfg.
-------- Original-Nachricht --------
Datum: Tue, 23 Oct 2012 09:28:57 +0200 Von: "Thomas Bächler" <thomas@archlinux.org> An: arch-general@archlinux.org Betreff: Re: [arch-general] Exiting wpa_supplicant Am 23.10.2012 02:42, schrieb Rafael Beraldo:
That's interesting. Why is that a bad idea? I used to do it by hand, waiting for wpa_supplicant to stablish a connection and then running dhcp. You wait for 10 seconds. That is way too long. A wireless connection is usually established within 3 seconds. Or not.
You wait for 10 seconds. That is way too short. A wireless connection may take 30 or even 60 seconds to establish.
A wireless connection may go up and down. It may stay down. Or come back up. You need to react to these changes.
Luckily, dhcpcd can partially handle this these days and you can simply start dhcpcd without delay, and it will figure out when to request an IP.
Hi, Thomas,
the delay of 10 seconds is recommended by the computing centre which maintains the university-wide WLAN. Without the delay dhcpcd returns a timeout.
Your reasons against wpa_supplicant are conclusive but neither netcfg nor wicd (which I would prefer) are supported here. Especially the encryption method that I have to configure in wicd is not documented.
Kind regards, Nelson. hi nelson, i used to do it just like you with a hacky script. after looking into netcfg i realized, that it does the exact same like my script before, but way better. you can even keep your config file for wpa_supplicant. you universitys computing centre just dont know the awesomeness of arch… just have a look at the wiki, youll figure it out easily. georg
[2012-10-22 17:57:30 +0200] Nelson Marambio:
I use wpa_supplicant in combination with the -B switch to establish the connection. After a pause of 10 seconds I pull an IP address by calling dhcpcd.
This 10-second sleep is flaky. Instead, after you've started wpa_supplicant, run `wpa_cli -a /path/to/script -B` with a script roughly looking like: case "$2" in CONNECTED) [[ -f /run/dhcpcd-$1.pid ]] && dhcpcd -qx $1 dhcpcd -q $1 ;; DISCONNECTED) dhcpcd -qx $1 ;; esac -- Gaetan
participants (8)
-
G. Schlisio
-
Gaetan Bisson
-
Leonid Isaev
-
Nelson Marambio
-
nelsonmarambio@gmx.de
-
Rafael Beraldo
-
Ray Kohler
-
Thomas Bächler