]> granicus.if.org Git - ejabberd/commitdiff
* src/ejabberd_config.erl: Print error when the configuration
authorBadlop <badlop@process-one.net>
Mon, 26 Nov 2007 19:52:09 +0000 (19:52 +0000)
committerBadlop <badlop@process-one.net>
Mon, 26 Nov 2007 19:52:09 +0000 (19:52 +0000)
requires ODBC, MySQL or PostgreSQL libraries but are not
installed (EJAB-210).

SVN Revision: 986

ChangeLog
src/ejabberd_config.erl

index 0fe7dfa8ad7604da819482ffa60d11fcdfe5e13d..3334f3e83bc34ac8187371f12fb1319e1a3e6e9e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2007-11-26  Badlop  <badlop@process-one.net>
 
+       * src/ejabberd_config.erl: Print error when the configuration 
+       requires ODBC, MySQL or PostgreSQL libraries but are not 
+       installed (EJAB-210).
+
        * src/web/ejabberd_web_admin.erl: Added a favicon (EJAB-379).
 
        * src/msgs/wa.msg: New Walon translation (thanks to 
index f029dca3887f00facb065e799f981035914ec1cc..8ee8612cdf89d220a5c9238f1ff685cb0ca16430 100644 (file)
@@ -161,6 +161,9 @@ process_host_term(Term, Host, State) ->
            State;
        {hosts, Hosts} ->
            State;
+       {odbc_server, ODBC_server} ->
+           odbc_modules_found = check_odbc_modules(ODBC_server),
+           add_option({odbc_server, Host}, ODBC_server, State);
        {Opt, Val} ->
            add_option({Opt, Host}, Val, State)
     end.
@@ -269,3 +272,32 @@ get_local_option(Opt) ->
     end.
 
 
+check_odbc_modules(ODBC_server) ->
+    case catch check_odbc_modules2(ODBC_server) of
+       {'EXIT', {undef, [{Module, module_info, []} | _]}} ->
+           ?CRITICAL_MSG("ejabberd is configured to use ODBC, but the Erlang module '~p' is not installed.", [Module]),
+           odbc_module_not_found;
+       _ -> odbc_modules_found
+    end.
+
+check_odbc_modules2(ODBC_server) ->
+    check_modules_exists([ejabberd_odbc, ejabberd_odbc_sup, odbc_queries]),
+    case ODBC_server of
+       {mysql, _Server, _DB, _Username, _Password} ->
+           check_modules_exists([mysql, mysql_auth, mysql_conn, mysql_recv]);
+       
+       {mysql, _Server, _Port, _DB, _Username, _Password} ->
+           check_modules_exists([mysql, mysql_auth, mysql_conn, mysql_recv]);
+       
+       {pgsql, _Server, _DB, _Username, _Password} ->
+           check_modules_exists([pgsql, pgsql_proto, pgsql_tcp, pgsql_util]);
+       
+       {pgsql, _Server, _Port, _DB, _Username, _Password} ->
+           check_modules_exists([pgsql, pgsql_proto, pgsql_tcp, pgsql_util]);
+       
+       Server when is_list(Server) ->
+           ok
+    end.
+
+check_modules_exists(Modules) ->
+    [true = is_list(Module:module_info()) || Module <- Modules].