mirror of
https://github.com/processone/ejabberd
synced 2025-10-03 09:49:18 +02:00
Adds optional post_install and pre_uninstall hooks (thanks Igor Manturov Jr.)(#1300)
This commit is contained in:
parent
56b30ab598
commit
fc7e52df71
1 changed files with 8 additions and 1 deletions
|
@ -170,7 +170,10 @@ install(Package) when is_binary(Package) ->
|
||||||
ok ->
|
ok ->
|
||||||
code:add_patha(module_ebin_dir(Module)),
|
code:add_patha(module_ebin_dir(Module)),
|
||||||
ejabberd_config:reload_file(),
|
ejabberd_config:reload_file(),
|
||||||
ok;
|
case erlang:function_exported(Module, post_install, 0) of
|
||||||
|
true -> Module:post_install();
|
||||||
|
_ -> ok
|
||||||
|
end;
|
||||||
Error ->
|
Error ->
|
||||||
delete_path(module_lib_dir(Module)),
|
delete_path(module_lib_dir(Module)),
|
||||||
Error
|
Error
|
||||||
|
@ -183,6 +186,10 @@ uninstall(Package) when is_binary(Package) ->
|
||||||
case installed(Package) of
|
case installed(Package) of
|
||||||
true ->
|
true ->
|
||||||
Module = jlib:binary_to_atom(Package),
|
Module = jlib:binary_to_atom(Package),
|
||||||
|
case erlang:function_exported(Module, pre_uninstall, 0) of
|
||||||
|
true -> Module:pre_uninstall();
|
||||||
|
_ -> ok
|
||||||
|
end,
|
||||||
[catch gen_mod:stop_module(Host, Module)
|
[catch gen_mod:stop_module(Host, Module)
|
||||||
|| Host <- ejabberd_config:get_myhosts()],
|
|| Host <- ejabberd_config:get_myhosts()],
|
||||||
code:purge(Module),
|
code:purge(Module),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue