From 00e32ee4b60654a2d9cfdc3aaf2f1a21a622eaa2 Mon Sep 17 00:00:00 2001 From: Christophe Romain Date: Thu, 16 Nov 2017 14:48:47 +0100 Subject: [PATCH] Allow writing custom modules in own path (#1327) in ejabberdctl, just add this to EJABBERD_OPTS external_beams /path/to/my/beams then all beams file /path/to/my/beams/*.beam will be known by ejabberd_config, and allowed to be loaded. --- src/ejabberd_config.erl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index 4b7c15806..83e8df641 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -978,7 +978,19 @@ default_db(Opt, Host, Module) -> get_modules() -> {ok, Mods} = application:get_key(ejabberd, modules), ExtMods = [Name || {Name, _Details} <- ext_mod:installed()], - ExtMods ++ Mods. + case application:get_env(ejabberd, external_beams) of + {ok, Path} -> + case lists:member(Path, code:get_path()) of + true -> ok; + false -> code:add_patha(Path) + end, + Beams = filelib:wildcard(filename:join(Path, "*\.beam")), + CustMods = [list_to_atom(filename:rootname(filename:basename(Beam))) + || Beam <- Beams], + CustMods ++ ExtMods ++ Mods; + _ -> + ExtMods ++ Mods + end. get_modules_with_options(Modules) -> lists:foldl(