wpa_supplicant 583 B

1234567891011121314151617181920
  1. #!/usr/bin/lua
  2. local uci = require('simple-uci').cursor()
  3. local ifnames = {}
  4. uci:foreach('wireless', 'wifi-iface',
  5. function(s)
  6. table.insert(ifnames, s['.name'])
  7. end
  8. )
  9. for _, ifname in ipairs(ifnames) do
  10. local iface = uci:get_all('wireless', ifname)
  11. if not uci:get_bool('wireless', ifname, 'disabled') and iface.mode == 'sta' and iface.ifname and iface.device and iface.ssid then
  12. local command = 'iw dev ' .. iface.ifname .. ' connect -w ' .. iface.ssid
  13. if iface.bssid then
  14. command = command .. ' ' .. iface.bssid
  15. end
  16. os.execute(command)
  17. end
  18. end