25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-02 16:37:52 +01:00

* src/ejabberd_check.erl: Detect correctly MSSQL and ODBC

configuration (EJAB-710)

SVN Revision: 1536
This commit is contained in:
Badlop 2008-08-25 12:08:22 +00:00
parent 2cda62dceb
commit b338dd671f
2 changed files with 21 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2008-08-25 Badlop <badlop@process-one.net>
* src/ejabberd_check.erl: Detect correctly MSSQL and ODBC
configuration (EJAB-710)
2008-08-24 Geoff Cant <gcant@process-one.net>
* src/mod_mud/mod_muc_room.erl: is_visitor/2 fix - use get_role

View File

@ -39,19 +39,21 @@
libs() ->
ok.
%% Consistency check on ejabberd configuration
%% @doc Consistency check on ejabberd configuration
config() ->
check_database_modules().
check_database_modules() ->
[check_database_module(M)||M<-get_db_used()].
check_database_module(odbc) ->
check_modules(odbc, [odbc, odbc_app, odbc_sup, ejabberd_odbc, ejabberd_odbc_sup, odbc_queries]);
check_database_module(mysql) ->
check_modules(mysql, [mysql, mysql_auth, mysql_conn, mysql_recv]);
check_database_module(pgsql) ->
check_modules(pgsql, [pgsql, pgsql_proto, pgsql_tcp, pgsql_util]).
%% Issue a critical error and throw an exit if needing module is
%% @doc Issue a critical error and throw an exit if needing module is
%% missing.
check_modules(DB, Modules) ->
case get_missing_modules(Modules) of
@ -63,7 +65,7 @@ check_modules(DB, Modules) ->
end.
%% Return the list of undefined modules
%% @doc Return the list of undefined modules
get_missing_modules(Modules) ->
lists:filter(fun(Module) ->
case catch Module:module_info() of
@ -73,7 +75,7 @@ get_missing_modules(Modules) ->
end
end, Modules).
%% Return the list of databases used
%% @doc Return the list of databases used
get_db_used() ->
%% Retrieve domains with a database configured:
Domains =
@ -86,14 +88,22 @@ get_db_used() ->
case check_odbc_option(
ejabberd_config:get_local_option(
{auth_method, Domain})) of
true -> [element(1, DB)|Acc];
true -> [get_db_type(DB)|Acc];
_ -> Acc
end
end,
[], Domains),
lists:usort(DBs).
%% Return true if odbc option is used
%% @doc Depending in the DB definition, return which type of DB this is
%% Note that MSSQL is detected as ODBC.
%% @spec (DB) -> mysql | pgsql | odbc
get_db_type(DB) when is_tuple(DB) ->
element(1, DB);
get_db_type(DB) when is_list(DB) ->
odbc.
%% @doc Return true if odbc option is used
check_odbc_option(odbc) ->
true;
check_odbc_option(AuthMethods) when is_list(AuthMethods) ->