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