hypriot / flash

Command line script to flash SD card images of any kind
MIT License
1k stars 176 forks source link

#109: wifi params to user-data #165

Closed WillWritesCode closed 4 years ago

WillWritesCode commented 4 years ago

added

StefanScherer commented 4 years ago

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 commented 4 years ago

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.

WillWritesCode commented 4 years ago

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

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...