merge-config.escript 885 B

1234567891011121314151617181920212223242526
  1. #!/usr/bin/env escript
  2. %% This script reads up emqx.conf and split the sections
  3. %% and dump sections to separate files.
  4. %% Sections are grouped between CONFIG_SECTION_BGN and
  5. %% CONFIG_SECTION_END pairs
  6. %%
  7. %% NOTE: this feature is so far not used in opensource
  8. %% edition due to backward-compatibility reasons.
  9. -mode(compile).
  10. main(_) ->
  11. BaseConf = "apps/emqx_machine/etc/emqx_machine.conf",
  12. {ok, Bin} = file:read_file(BaseConf),
  13. Apps = filelib:wildcard("*", "apps/"),
  14. Conf = lists:foldl(fun(App, Acc) ->
  15. Filename = filename:join([apps, App, "etc", App]) ++ ".conf",
  16. case filelib:is_regular(Filename) of
  17. true ->
  18. {ok, Bin1} = file:read_file(Filename),
  19. [Acc, io_lib:nl(), Bin1];
  20. false -> Acc
  21. end
  22. end, Bin, Apps),
  23. ok = file:write_file("apps/emqx_machine/etc/emqx.conf.all", Conf).