510-autoupdater-wifi-fallback 869 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/lua
  2. local uci = require 'luci.model.uci'.cursor()
  3. local site = require 'gluon.site_config'
  4. local util = require 'gluon.util'
  5. local fs = require('nixio.fs')
  6. local sysctl = require 'gluon.sysctl'
  7. local radios = {}
  8. uci:foreach('wireless', 'wifi-device',
  9. function(s)
  10. table.insert(radios, s['.name'])
  11. end
  12. )
  13. for _, radio in ipairs(radios) do
  14. uci:delete('wireless', 'fallback')
  15. uci:section('wireless', 'wifi-iface', 'fallback',
  16. {
  17. device = radio,
  18. network = 'fallback',
  19. mode = 'sta',
  20. ssid = site.wifi24.ap.ssid,
  21. disabled = 1,
  22. macaddr = util.generate_mac(3, 10),
  23. ifname = 'fallback',
  24. encryption = 'none',
  25. }
  26. )
  27. end
  28. uci:delete('network','fallback')
  29. uci:section('network', 'interface', 'fallback',
  30. {
  31. ifname = 'fallback',
  32. }
  33. )
  34. uci:save('wireless')
  35. uci:save('network')
  36. uci:commit('wireless')
  37. uci:commit('network')