]> granicus.if.org Git - ejabberd/commitdiff
Adds optional post_install and pre_uninstall hooks (thanks Igor Manturov Jr.)(#1300)
authorChristophe Romain <christophe.romain@process-one.net>
Mon, 28 Nov 2016 16:15:57 +0000 (17:15 +0100)
committerChristophe Romain <christophe.romain@process-one.net>
Mon, 28 Nov 2016 16:15:57 +0000 (17:15 +0100)
src/ext_mod.erl

index 071fb827c3c6d277c9c4d36a3b80b2d580dcc87e..5b970623b6e63f19574b96e8add1c98f361dd89b 100644 (file)
@@ -170,7 +170,10 @@ install(Package) when is_binary(Package) ->
                 ok ->
                     code:add_patha(module_ebin_dir(Module)),
                     ejabberd_config:reload_file(),
-                    ok;
+                    case erlang:function_exported(Module, post_install, 0) of
+                        true -> Module:post_install();
+                        _ -> ok
+                    end;
                 Error ->
                     delete_path(module_lib_dir(Module)),
                     Error
@@ -183,6 +186,10 @@ uninstall(Package) when is_binary(Package) ->
     case installed(Package) of
         true ->
             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)
              || Host <- ejabberd_config:get_myhosts()],
             code:purge(Module),