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

#109: wifi params to user-data #165

Merged

Conversation

WillWritesCode
Copy link

added

  • naive implementation of SSID/PSK settings to user-data
  • basic tests to try to cover this

added
* naive implementation of SSID/PSK settings to user-data
* basic tests to try to cover this
@StefanScherer
Copy link
Member

Thank you for the contribution and the tests!
I have to look closer and test a bit.
To make this work the user has to remove the comment signs in https://github.com/hypriot/image-builder-rpi/blob/master/builder/files/boot/user-data#L40-L59
Maybe we should mark this comment block a little different to easily do a sed_i to uncomment the block.

@WillWritesCode
Copy link
Author

WillWritesCode commented Jan 24, 2020

We should be able to add something like ^[^#] as the first term in sed_i like:
sed_i -e "/^#/s/.*ssid=.*\$/ ssid=\"${WIFI_SSID}\"/" "${boot}/user-data"

That way it leaves comments alone.
Probably needs different tests files (one with the section commented, one not) + check it doesn’t affect the commented version.

Will added 2 commits January 26, 2020 12:11
* should negate for commented lines

Tests
* user-data test files - wifi commented and uncommented
* new tests fo mixing params for user-data & wifi creds
* new refute test - commented ssid/psk lines should be unchanged
* fixes to pass tests

Now ignores wifi params for user-data if the wifi section is commented.

That means basic implementation works if also using a user-data file where the wifi section is present and not commented.
@WillWritesCode
Copy link
Author

WillWritesCode commented Jan 26, 2020

I've just pushed some changes to prevent the sed_i for commented lines.

Probably not enough to close issue #109, but would cover my use-case

  • requires a custom (static) user-data file to be specified with uncommented wifi credentials/section
    • means it can be used easily on CLI to change wifi creds on deploy
    • (my use-case has a custom commands running on init, so I have a custom user-data file anyway)
  • doesn't do anything with the default image and no custom user-data file

As you said @StefanScherer, an alternative marking of the wifi comment block might be an option to make a full implementation simpler, or just copy in the entire wifi section if no uncommented section is found...

Copy link
Member

@StefanScherer StefanScherer left a comment

Choose a reason for hiding this comment

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

Let's merge this, it is at least an improvement to have this parameters work again.
Thanks for the test cases!
LGTM

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

2 participants