|
@@ -0,0 +1,27 @@
|
|
|
+#!/usr/bin/lua
|
|
|
+
|
|
|
+local fs = require 'nixio.fs'
|
|
|
+
|
|
|
+
|
|
|
+if not fs.access('/lib/gluon/domains/') then
|
|
|
+ return
|
|
|
+end
|
|
|
+
|
|
|
+
|
|
|
+local uci = require('simple-uci').cursor()
|
|
|
+
|
|
|
+local domain = uci:get('gluon', 'core', 'domain')
|
|
|
+if domain and not fs.access('/lib/gluon/domains/' .. domain .. '.json') then
|
|
|
+ io.stderr:write(string.format("Warning: invalid mesh domain '%s' configured, resetting to default...\n", domain))
|
|
|
+ domain = nil
|
|
|
+end
|
|
|
+
|
|
|
+if domain then return end
|
|
|
+
|
|
|
+
|
|
|
+-- We can't use gluon.site yet, as it depends on gluon.core.domain to be set
|
|
|
+local json = require 'jsonc'
|
|
|
+local site = assert(json.load('/lib/gluon/site.json'))
|
|
|
+
|
|
|
+uci:set('gluon', 'core', 'domain', site.default_domain)
|
|
|
+uci:commit('gluon')
|