-
Notifications
You must be signed in to change notification settings - Fork 3
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
Support wpa_supplicant.conf.txt, convert DOS line endings to UNIX to keep wpa_supplicant happy #4
base: master
Are you sure you want to change the base?
Conversation
This would also handle the same issue where the user creates the wpa_supplicant.conf file on macOS, since it also appends .txt to the filename - see raspberrypi/documentation#1672 (comment). |
It should also be fairly easy to convert from DOS newlines to Unix newlines. The solution is probably not dos2unix, since that also does codespace conversion. |
https://stackoverflow.com/questions/2613800/how-to-convert-dos-windows-newline-crlf-to-unix-newline-lf-in-a-bash-script has lots of different alternatives. |
I was referring to doing automatic linewrap conversion on the wpa_supplicant.conf{,.txt} file when we copy it across from the boot filesystem. |
It doesn't really matter if the shell commands are embedded in the unit file, or whether they are in the form of a separate shell script. I'm not sure which is actually easier, since the code is more readable on multiple lines, but putting it into the unit file saves having to have another file somewhere. |
Just in case you missed my earlier comment: (the way GH auto-hides some comments can be a bit too aggressive IMHO) |
Yup, I knew exactly that's what you were referring to 🙂
And yup, that's exactly the decision I was deferring to Serge or Simon 😀 (since they'll be the ones maintaining this) |
The unit file worked as I have written it - the cut and paste was to get it into github as I'm not running it locally. |
Good change and good suggestions. I would separate it out into a secondary script that lives in I don't understand the issue with using dos2unix, so I can't really comment on that, but I'm happy with whatever works. I can make the changes myself later of pull them in if you get to them first. |
It turns out there isn't one - I had misread the docs. |
OK, that's this ready to go. Because of occasional problems I've seen with some Mac users seeing unexpected characters, in the form of specific left and right single quotes, getting inserted in place of single quotation marks, I've asked dos2unix to perform a conversion to 7-bit ASCII. This is just as likely to mangle those characters, but that will at least make it obvious upon inspection that the character should not be there, although if the user can't get onto the machine then of course this won't really be much help. |
Fixed typo in unit file after testing. |
Could that also cause problems if the user has "unusual" characters in their wifi password? 🤷♂️ |
Good point. From memory wpasupplicant expects the psk to be ASCII, which could be 7 or 8 bit. I shall remove the -7 flag. |
This is now complete, I think, and I have addressed lurch's review comment. I still need to test this as a package. Please do not integrate this until I do. |
Note that this pulls in a new package to the default install of Raspberry Pi OS, namely |
OK, I've tested the package as working on my Pi. It should therefore be safe to integrate. |
Inspired by the variant handling of ssh and ssh.txt, and raspberrypi/documentation#1672, let's make the process of providing a custom wpa_supplicant.conf via the boot filesystem a little easier and support the case where the user has unwittingly created the file as wpa_supplicant.conf.txt.
Tested on Raspberry Pi OS. I also looked up whether the long line would work OK in systemd - there seems to be a 2048 character line length limit, which this unit file is nowhere near.
My rationale is that it is currently somewhat tricky to get the wpa_supplicant.conf file created and working correctly. Taking this, and line wrap conversion out of the hands of the user will remove two of the gotchas. The other gotcha is getting the right incantations in the file for the particular version of wpa_supplicant we are using.