Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wpa_supplicant usage #397

Merged
merged 22 commits into from Jun 16, 2016
Merged

wpa_supplicant usage #397

merged 22 commits into from Jun 16, 2016

Conversation

Mausy5043
Copy link
Contributor

@Mausy5043 Mausy5043 commented Mar 28, 2016

Changes:

  1. Put all networking related code together.
  2. If config/wpa_supplicant.conf exists AND was used by the installer then copy it to the installed system in /etc/wpa_supplicant/ and add a reference to it in /etc/network/interfaces.
  3. Changed the way of installing and starting wpa_supplicant so that it actually works.

This commit will allow the user to install AND use the target system in the absence of a wired ethernet connection, but in the presence of a WiFi network.

The user must configure the following (already existing) parameters:

  1. drivers_to_load= supply the name of the module that must be loaded by the kernel for the hardware (WiFi dongle) used. E.g.: 8192cu.
  2. ifname= supply the non-ethernet interface name. Normally you will use wlan0 here.

Additionally user must supply a file (config/wpa_supplicant.conf) containing a valid configuration. E.g.:

network={
ssid="pi3.1415926"
psk="AV3ry53cretPa55w0rdThatN00n3W!113verGue55"
key_mgmt=WPA-PSK
}

ref: https://w1.fi/cgit/hostap/plain/wpa_supplicant/wpa_supplicant.conf
(Please don't use the password suggested in the example above. It is not secure)

fi
# lo interface may already be there, so first check for it
if ! grep -q "auto lo" /rootfs/etc/network/interfaces; then
echo "auto lo" >> /rootfs/etc/network/interfaces
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't use weird alignment like this

@Mausy5043
Copy link
Contributor Author

bump

@Mausy5043
Copy link
Contributor Author

Mausy5043 commented Apr 24, 2016

This PR fixes #175 which IMHO was never properly tested (due to lack of hardware for testing).
This PR solves #44 and #349.
This PR may be of help finding a solution for #52

EDIT: please note I've updated the description at the top.

wpa_supplicant -B -Dnl80211,wext -c/bootfs/config/wpa_supplicant.conf -i$ifname >& /dev/null || fail
echo "OK"
echo "Starting wpa_supplicant... "
wpa_supplicant -B -Dnl80211 -c/bootfs/config/wpa_supplicant.conf -i$ifname
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are nl80211 and wext the only two supported modules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also wired.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we don't need wpa_supplicant for wired connections 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😋 I meant for wireless... 😊

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for this change?
The whole idea of -Dnl80211,wext is to try nl80211 first and if that doesn't work, try wext.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't work with -Dnl80211,wext 😕 . It turned out during testing that it only worked if I tried them separately.

@@ -1115,6 +1121,15 @@ if [ -e /bootfs/post-install.txt ]; then
echo "================================================="
fi

# modify installed network settings
if [ -f /rootfs/etc/wpa_supplicant/wpa_supplicant.conf ]; then
if [ $(grep "iface" /rootfs/etc/network/interfaces |grep -v "lo\|eth0" |wc -l) -ne 0 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add spaces after the pipe characters (the actual pipes, not the character in the regex 😉 )

@goranche
Copy link
Contributor

goranche commented May 7, 2016

💭 maybe it would be better to check the interface name for wlan* instead of not eth0...
a possible problem I see is it anyone has additional non-wifi interfaces...

@diederikdehaas
Copy link
Member

better to check the interface name for wlan* instead of not eth0

Ra-link devices get named ra* and those are wireless devices.
What do you mean with additional non-wifi interfaces (that could pose a problem)?

@Mausy5043
Copy link
Contributor Author

a possible problem I see is it anyone has additional non-wifi interfaces...

Let's cross that bridge when we get there.

@goranche
Copy link
Contributor

goranche commented May 7, 2016

What do you mean with additional non-wifi interfaces (that could pose a problem)?

I was thinking a bit too far ahead... this is a larger part of my interfaces file:

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

the code as is wouldn't create both wpa-conf entries... but on the other hand (this is where I didn't think it through) you can't really add multiple interfaces anyway, so... never mind 😉

@goranche
Copy link
Contributor

goranche commented May 7, 2016

Ra-link devices get named ra*

groan

echo "wpa-conf /boot/config/wpa_supplicant.conf"
# eth0 config
echo "" >> /rootfs/etc/network/interfaces
echo "auto $ifname" >> /rootfs/etc/network/interfaces
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With wireless interfaces, you usually also want allow-hotplug $ifname as wireless devices are more likely to get unplugged and replugged, but also it will give a signal when the device is ready to be used by which the auto may already have passed.

@goranche
Copy link
Contributor

goranche commented May 7, 2016

I do have one more thing, though... if we install using WiFi, we don't create an entry for eth0...

I think that in this case we should create an entry with dhcp:

allow-hotplug eth0
iface eth0 inet dhcp

this way the ethernet port will still work if a cable is plugged in...

@diederikdehaas
Copy link
Member

diederikdehaas commented May 7, 2016

I'm not sure where to put it, so I'll just do it here.
The wireless part of my /e/n/i is as follows:

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Note the manual value and the extra iface ... line at the bottom

@goranche
Copy link
Contributor

goranche commented May 7, 2016

Not the manual value and the extra iface ... line at the bottom

I have manual in there as well (interestingly, for eth0 as well, as said, taken from the official raspbian)...

what is a default iface?

@diederikdehaas
Copy link
Member

what is a default iface?

I actually don't know, I just know that I see that all the time and it also always works here.

@Mausy5043
Copy link
Contributor Author

Mausy5043 commented May 7, 2016

what is a default iface?

I actually don't know, I just know that I see that all the time and it also always works here.

I've never used it. So, I hope you don't mind me not adding it. It works fine without.
Agree with the auto and hotplug entries. Will add those.

@Mausy5043
Copy link
Contributor Author

Mind you that not adding the eth0 interface here, doesn't mean it won't work.
It actually still will.
So, I'm adding entries for eth0 per your (2) request. But, it is not needed.

 both `wlan` and `eth0` with `auto` and `hotplug`
@Mausy5043
Copy link
Contributor Author

Done.

@goranche
Copy link
Contributor

goranche commented May 7, 2016

not adding the eth0 interface here, doesn't mean it won't work

huh? really? why? how? I NEED ANSWERS!!! 😁

no, but really... how?

@Mausy5043
Copy link
Contributor Author

Mausy5043 commented May 8, 2016

I have no idea. It just does.
Just guessing, but could it be dhclient?

@goranche
Copy link
Contributor

goranche commented May 8, 2016

could it be dhclient

it shouldn't be, AFAIK, if the interface isn't listed (to be brought up) in the interfaces file... 💭

@diederikdehaas
Copy link
Member

FWIW I share goranche's skepticism.

@Mausy5043
Copy link
Contributor Author

OK. No problem. The eth0 definition has already been added as you requested so ... the discussion is moot anyway,

@diederikdehaas diederikdehaas merged commit 7c1ab28 into debian-pi:v1.1.x Jun 16, 2016
@diederikdehaas
Copy link
Member

Next time I will require that you'll squash commits together 😉

I noticed that when you only have a wireless device plugged in, the boot process takes quite a long time because it's waiting for eth0, so you (@Mausy5043) may have had more of a point then I anticipated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants