Browse Source

ffho-domain-migration: move regex into site.conf

Karsten Böddeker 6 years ago
parent
commit
ca4cc1b87e

+ 5 - 0
ffho/ffho-domain-migration/Makefile

@@ -34,4 +34,9 @@ define Package/ffho-domain-migration/install
 	$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
 endef
 
+define Package/ffho-domain-migration/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
 $(eval $(call BuildPackage,ffho-domain-migration))

+ 1 - 0
ffho/ffho-domain-migration/check_site.lua

@@ -0,0 +1 @@
+need_string(in_site({'domain_migration', 'match'}, false))

+ 9 - 1
ffho/ffho-domain-migration/luasrc/lib/gluon/upgrade/002-domain-migration

@@ -13,7 +13,15 @@ if uci:get('gluon', 'system') then
 end
 if fs.stat(file) then
 	local domain = uci:get('currentsite', 'current', 'name')
-	uci:set('gluon', 'core', 'domain', domain:match('^ffho_(.*)$') or domain)
+
+	-- 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'))
+
+	if (site.domain_migration or {}).match then
+		domain = domain:match(site.domain_migration.match) or domain
+	end
+	uci:set('gluon', 'core', 'domain', domain)
 	fs.remove(file)
 end