check_site.lua 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_match('next_node.ip6', '^[%x:]+$', false)
  35. need_string_match('next_node.ip4', '^%d+.%d+.%d+.%d+$', false)
  36. end
  37. for _, config in ipairs({'wifi24', 'wifi5'}) do
  38. local rates = {1000, 2000, 5500, 6000, 9000, 11000, 12000, 18000, 24000, 36000, 48000, 54000}
  39. rates = need_array_of(config .. '.supported_rates', rates, false) or rates
  40. if need_table(config .. '.ibss', nil, false) then
  41. need_string(config .. '.ibss.ssid')
  42. need_string_match(config .. '.ibss.bssid', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')
  43. need_one_of(config .. '.ibss.mcast_rate', rates, false)
  44. need_number(config .. '.ibss.vlan', false)
  45. need_boolean(config .. '.ibss.disabled', false)
  46. end
  47. if need_table(config .. '.mesh', nil, false) then
  48. need_string(config .. '.mesh.id')
  49. need_one_of(config .. '.mesh.mcast_rate', rates, false)
  50. need_boolean(config .. '.mesh.disabled', false)
  51. end
  52. end
  53. need_boolean('mesh_on_wan', false)
  54. need_boolean('mesh_on_lan', false)
  55. need_boolean('single_as_lan', false)