25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

* src/ejabberd_ctl.erl: Added command for listing all registered

users

* src/ejabberd_ctl.erl: Bugfix, support for text-load and restore
(thanks to Leif Johansson)

SVN Revision: 229
This commit is contained in:
Alexey Shchepin 2004-05-05 20:34:54 +00:00
parent a16524151c
commit f7275fb796
2 changed files with 65 additions and 16 deletions

View File

@ -1,3 +1,11 @@
2004-05-05 Alexey Shchepin <alexey@sevcom.net>
* src/ejabberd_ctl.erl: Added command for listing all registered
users
* src/ejabberd_ctl.erl: Bugfix, support for text-load and restore
(thanks to Leif Johansson)
2004-05-04 Alexey Shchepin <alexey@sevcom.net>
* src/web/ejabberd_web_admin.erl: Updated

View File

@ -72,7 +72,7 @@ process(Node, ["unregister", User]) ->
process(Node, ["backup", Path]) ->
case rpc:call(Node, mnesia, backup, [Path]) of
{atomic, ok} ->
ok ->
ok;
{error, Reason} ->
io:format("Can't store backup in ~p on node ~p: ~p~n",
@ -82,6 +82,30 @@ process(Node, ["backup", Path]) ->
[Path, Node, Reason])
end;
process(Node, ["dump", Path]) ->
case rpc:call(Node, mnesia, dump_to_textfile, [Path]) of
ok ->
ok;
{error, Reason} ->
io:format("Can't store dump in ~p on node ~p: ~p~n",
[Path, Node, Reason]);
{badrpc, Reason} ->
io:format("Can't store dump in ~p on node ~p: ~p~n",
[Path, Node, Reason])
end;
process(Node, ["load", Path]) ->
case rpc:call(Node, mnesia, load_textfile, [Path]) of
ok ->
ok;
{error, Reason} ->
io:format("Can't load dump in ~p on node ~p: ~p~n",
[Path, Node, Reason]);
{badrpc, Reason} ->
io:format("Can't load dump in ~p on node ~p: ~p~n",
[Path, Node, Reason])
end;
process(Node, ["restore", Path]) ->
case rpc:call(Node,
mnesia, restore, [Path, [{default_op, keep_tables}]]) of
@ -107,24 +131,41 @@ process(Node, ["install-fallback", Path]) ->
[Path, Node, Reason])
end;
process(Node, ["registered-users"]) ->
case rpc:call(Node, ejabberd_auth, dirty_get_registered_users, []) of
Users when is_list(Users) ->
NewLine = io_lib:format("~n", []),
SUsers = lists:sort(Users),
FUsers = lists:map(fun(U) -> [U, NewLine] end, SUsers),
io:format("~s", [FUsers]),
ok;
{ErrorTag, Reason} when (ErrorTag == error) or (ErrorTag == badrpc) ->
io:format("Can't get list of registered users on node ~p: ~p~n",
[Node, Reason])
end;
process(_Node, _Args) ->
print_usage().
print_usage() ->
io:format("Usage: ejabberdctl node command~n"
"~n"
"Available commands:~n"
" stop\t\t\t\tstop ejabberd~n"
" restart\t\t\trestart ejabberd~n"
" reopen-log\t\t\treopen log file~n"
" register user password\tregister a user~n"
" unregister user\t\tunregister a user~n"
" backup file\t\t\tstore a backup in file~n"
" restore file\t\t\trestore a backup from file~n"
" install-fallback file\t\tinstall a fallback from file~n"
"~n"
"Example:~n"
" ejabberdctl ejabberd@host restart~n"
).
io:format(
"Usage: ejabberdctl node command~n"
"~n"
"Available commands:~n"
" stop\t\t\t\tstop ejabberd~n"
" restart\t\t\trestart ejabberd~n"
" reopen-log\t\t\treopen log file~n"
" register user password\tregister a user~n"
" unregister user\t\tunregister a user~n"
" backup file\t\t\tstore a database backup in file~n"
" restore file\t\t\trestore a database backup from file~n"
" install-fallback file\t\tinstall a database fallback from file~n"
" dump file\t\t\tdump a database in a text file~n"
" load file\t\t\trestore a database from a text file~n"
" registered-users\t\tlist all registered users~n"
"~n"
"Example:~n"
" ejabberdctl ejabberd@host restart~n"
).