002-domain-migration 627 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/lua
  2. local sys_stat = require 'posix.sys.stat'
  3. local uci = require("simple-uci").cursor()
  4. local file = '/etc/config/currentsite'
  5. if not uci:get('gluon', 'core') then
  6. uci:section('gluon', 'core', 'core')
  7. end
  8. if uci:get('gluon', 'system') then
  9. uci:delete('gluon', 'system')
  10. end
  11. if sys_stat.stat(file) then
  12. local domain = uci:get('currentsite', 'current', 'name')
  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', domain)
  17. os.remove(file)
  18. end
  19. uci:save('gluon')