check_site.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. need_string 'site_code'
  2. need_string 'site_name'
  3. if need_table('opkg', nil, false) then
  4. need_string('opkg.lede', false)
  5. function check_repo(k, _)
  6. -- this is not actually a uci name, but using the same naming rules here is fine
  7. assert_uci_name(k)
  8. need_string(string.format('opkg.extra[%q]', k))
  9. end
  10. need_table('opkg.extra', check_repo, false)
  11. end
  12. need_string('hostname_prefix', false)
  13. need_string 'timezone'
  14. need_string_array('ntp_servers', false)
  15. need_string_match('prefix6', '^[%x:]+/64$')
  16. for _, config in ipairs({'wifi24', 'wifi5'}) do
  17. if need_table(config, nil, false) then
  18. need_string('regdom') -- regdom is only required when wifi24 or wifi5 is configured
  19. need_number(config .. '.channel')
  20. local rates = {1000, 2000, 5500, 6000, 9000, 11000, 12000, 18000, 24000, 36000, 48000, 54000}
  21. local supported_rates = need_array_of(config .. '.supported_rates', rates, false)
  22. if supported_rates then
  23. need_array_of(config .. '.basic_rate', supported_rates, true)
  24. else
  25. need_array_of(config .. '.basic_rate', rates, false)
  26. end
  27. end
  28. end
  29. need_boolean('poe_passthrough', false)
  30. if need_table('dns', nil, false) then
  31. need_string_array_match('dns.servers', '^[%x:]+$', false)
  32. end
  33. if need_table('next_node', nil, false) then
  34. need_string('next_node.name', false)
  35. need_string_match('next_node.ip6', '^[%x:]+$', false)
  36. need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false)
  37. end
  38. for _, config in ipairs({'wifi24', 'wifi5'}) do
  39. local rates = {1000, 2000, 5500, 6000, 9000, 11000, 12000, 18000, 24000, 36000, 48000, 54000}
  40. rates = need_array_of(config .. '.supported_rates', rates, false) or rates
  41. if need_table(config .. '.ibss', nil, false) then
  42. need_string(config .. '.ibss.ssid')
  43. need_string_match(config .. '.ibss.bssid', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')
  44. need_one_of(config .. '.ibss.mcast_rate', rates, false)
  45. need_number(config .. '.ibss.vlan', false)
  46. need_boolean(config .. '.ibss.disabled', false)
  47. end
  48. if need_table(config .. '.mesh', nil, false) then
  49. need_string(config .. '.mesh.id')
  50. need_one_of(config .. '.mesh.mcast_rate', rates, false)
  51. need_boolean(config .. '.mesh.disabled', false)
  52. end
  53. end
  54. need_boolean('mesh_on_wan', false)
  55. need_boolean('mesh_on_lan', false)
  56. need_boolean('single_as_lan', false)