005-site-domain 678 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/lua
  2. local fs = require 'nixio.fs'
  3. if not fs.access('/lib/gluon/domains/') then
  4. return
  5. end
  6. local uci = require('simple-uci').cursor()
  7. local domain = uci:get('gluon', 'core', 'domain')
  8. if domain and not fs.access('/lib/gluon/domains/' .. domain .. '.json') then
  9. io.stderr:write(string.format("Warning: invalid mesh domain '%s' configured, resetting to default...\n", domain))
  10. domain = nil
  11. end
  12. if domain then return end
  13. -- We can't use gluon.site yet, as it depends on gluon.core.domain to be set
  14. local json = require 'jsonc'
  15. local site = assert(json.load('/lib/gluon/site.json'))
  16. uci:set('gluon', 'core', 'domain', site.default_domain)
  17. uci:commit('gluon')