chore: don't generate enterprise.conf when not emqx-enterprise profile

This commit is contained in:
Zhongwen Deng 2022-09-14 09:57:34 +08:00
parent 6a470dc3ac
commit 499ed3ca51
1 changed files with 15 additions and 7 deletions

View File

@ -12,13 +12,13 @@
-define(APPS, ["emqx", "emqx_dashboard", "emqx_authz"]).
main(_) ->
Profile = os:getenv("PROFILE", "emqx"),
{ok, BaseConf} = file:read_file("apps/emqx_conf/etc/emqx_conf.conf"),
Cfgs = get_all_cfgs("apps/"),
IsEnterprise = is_enterprise(),
Enterprise =
case Profile of
"emqx" -> [];
"emqx-enterprise" -> [io_lib:nl(), "include emqx-enterprise.conf", io_lib:nl()]
case IsEnterprise of
false -> [];
true -> [io_lib:nl(), "include emqx-enterprise.conf", io_lib:nl()]
end,
Conf = [
merge(BaseConf, Cfgs),
@ -27,10 +27,18 @@ main(_) ->
],
ok = file:write_file("apps/emqx_conf/etc/emqx.conf.all", Conf),
case IsEnterprise of
true ->
EnterpriseCfgs = get_all_cfgs("lib-ee/"),
EnterpriseConf = merge("", EnterpriseCfgs),
ok = file:write_file("apps/emqx_conf/etc/emqx-enterprise.conf.all", EnterpriseConf);
false ->
ok
end.
ok = file:write_file("apps/emqx_conf/etc/emqx-enterprise.conf.all", EnterpriseConf).
is_enterprise() ->
Profile = os:getenv("PROFILE", "emqx"),
nomatch =/= string:find(Profile, "enterprise").
merge(BaseConf, Cfgs) ->
lists:foldl(