ejabberd
ejabberd copied to clipboard
Wildcard support for include_config_file
Hi! Would you please consider to support wildcards for the include_config_file option in the ejabberd configuration?
Desired functionality:
All yml files in /etc/ejabberd/conf.d get the imported.
Actual functionality:
include_config_file: /etc/ejabberd/conf.d/*.yml does not expand the wildcard
BTW, the certfiles option supports wildcards, what is very convenient :-)
The minimal implementation could be something like this, in the yconf library that ejabberd uses to parse the yaml configuration files:
diff --git a/src/yconf.erl b/src/yconf.erl
index 8967067..d93868d 100644
--- a/src/yconf.erl
+++ b/src/yconf.erl
@@ -951,7 +951,15 @@ read_include_files(Includes, Opts, Paths) ->
end, Y);
(File) ->
read_yaml(File, Opts, Paths)
- end, Includes).
+ end, wildcard(Includes)).
+
+wildcard(Paths) when is_list(Paths) ->
+ lists:flatten([wildcard(Path) || Path <- Paths]);
+wildcard({Path, Opt}) ->
+ [{P, Opt} || P <- wildcard(Path)];
+wildcard(Path) when is_binary(Path) ->
+ Files = filelib:wildcard(binary_to_list(Path)),
+ [unicode:characters_to_binary(File) || File <- Files].
%%%===================================================================
%%% Auxiliary functions
For testing purposes, if you can't apply the patch to yconf, compile yconf and compile ejabberd, there's a simple solution: use this container image https://github.com/badlop/ejabberd/pkgs/container/ejabberd/24688553?tag=3804 which includes patched yconf and ejabberd.