25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

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.
This commit is contained in:
Christophe Romain 2017-11-16 14:48:47 +01:00
parent 44700d91ba
commit 00e32ee4b6

View File

@ -978,7 +978,19 @@ default_db(Opt, Host, Module) ->
get_modules() -> get_modules() ->
{ok, Mods} = application:get_key(ejabberd, modules), {ok, Mods} = application:get_key(ejabberd, modules),
ExtMods = [Name || {Name, _Details} <- ext_mod:installed()], 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) -> get_modules_with_options(Modules) ->
lists:foldl( lists:foldl(