0

I'm writing bash script that configure network access for my Linux devices.

The script has to be used by not Linux skilled people that has no administrative rights on the device. I wrote the ethernet interfaces configuration part and it's ok. Now I need write Wifi configuration part.

The end of the game is to write configuration inside a netplan configuration yaml file. Here the expected workflow of the script:

  1. manage interactive menu system retrieving Hi-level Wifi parameter (SSID, password, authentication mode, dhcp or manual configuration...)
  2. Check the Connectivity to the selected Access point
  3. Save data to netplan configuration yaml file
  4. Apply changes

Point 1, 3 and 4 are ok... also retrieving the list of the available access point is ok.

What I cannot achieve is the point 2 (Check the Connectivity to the selected Access point). I would like to have an use experience like the next

WIFI configuration parameters:
    SSID: My Network
    PSK:  password
Actions:
    - e: Edit
    - t: Test connectivity
    - s: Save
    - q: Quit
Select Action: t
....wait while testing connectivity
Test result: OK
Press a key to continue...

I tried with iwconfig but it's not working with WPA so it does not apply to the most cases.

I tried wpa_supplicant and I can do the test but not in the way I'm thinking... It's a foreground test that can be stopped only with ctrl-C and is hard to read for dummies (my final user taget).

I would like to

  1. launch the Wifi connection in background
  2. test in background if the connection to Access Point is ok or not
  3. close the Wifi connection in back ground (the final goal is to configure netplan)
  4. Return an OK/Fail response to calling script

Of course it is possible to run wpa_supplicant connection in bg but: how to check connectivity and stop it always in bg?

Any suggestion?

Thanks Sandro

0 Answers0