check_site.lua 2.3 KB

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