25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

* src/web/ejabberd_web_admin.erl: Added a interface for node

updating
* src/ejabberd_update.erl: Added function update_info/0

SVN Revision: 512
This commit is contained in:
Alexey Shchepin 2006-02-27 04:43:16 +00:00
parent 51c4ab8351
commit 20d049fe28
3 changed files with 71 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2006-02-27 Alexey Shchepin <alexey@sevcom.net>
* src/web/ejabberd_web_admin.erl: Added a interface for node
updating
* src/ejabberd_update.erl: Added function update_info/0
2006-02-25 Alexey Shchepin <alexey@sevcom.net>
* src/msgs/ru.msg: Updated (thanks to Sergei Golovan)

View File

@ -10,12 +10,25 @@
-author('alexey@sevcom.net').
%% API
-export([update/0]).
-export([update/0, update_info/0]).
%%====================================================================
%% API
%%====================================================================
update() ->
case update_info() of
{ok, Dir, _UpdatedBeams, _Script, _LowLevelScript, Check} ->
Eval =
release_handler_1:eval_script(
LowLevelScript, [],
[{ejabberd, "", filename:join(Dir, "..")}]),
io:format("eval: ~p~n", [Eval]),
Eval;
{error, Reason} ->
{error, Reason}
end.
update_info() ->
Dir = filename:dirname(code:which(ejabberd)),
case file:list_dir(Dir) of
{ok, Files} ->
@ -46,11 +59,7 @@ update() ->
LowLevelScript,
[{ejabberd, "", filename:join(Dir, "..")}]),
io:format("check: ~p~n", [Check]),
Eval =
release_handler_1:eval_script(
LowLevelScript, [],
[{ejabberd, "", filename:join(Dir, "..")}]),
io:format("eval: ~p~n", [Eval]);
{ok, Dir, UpdatedBeams, Script, LowLevelScript, Check};
{error, Reason} ->
{error, Reason}
end.

View File

@ -1841,7 +1841,8 @@ get_node(global, Node, [], Query, Lang) ->
[?LI([?ACT("db/", "Database")]),
?LI([?ACT("backup/", "Backup")]),
?LI([?ACT("ports/", "Listened Ports")]),
?LI([?ACT("stats/", "Statistics")])
?LI([?ACT("stats/", "Statistics")]),
?LI([?ACT("update/", "Update")])
]),
?XAE("form", [{"action", ""}, {"method", "post"}],
[?INPUTT("submit", "restart", "Restart"),
@ -2056,6 +2057,38 @@ get_node(global, Node, ["stats"], Query, Lang) ->
])
])];
get_node(global, Node, ["update"], Query, Lang) ->
rpc:call(Node, code, purge, [ejabberd_update]),
Res = node_update_parse_query(Node, Query),
rpc:call(Node, code, load_file, [ejabberd_update]),
{ok, Dir, UpdatedBeams, Script, LowLevelScript, Check} =
rpc:call(Node, ejabberd_update, update_info, []),
Mods =
case UpdatedBeams of
[] ->
?CT("None");
_ ->
?XE("ul",
[?LI([?C(atom_to_list(Beam))]) ||
Beam <- UpdatedBeams])
end,
FmtScript = ?XC("pre", io_lib:format("~p", [Script])),
FmtLowLevelScript = ?XC("pre", io_lib:format("~p", [LowLevelScript])),
[?XC("h1", ?T("Update ") ++ atom_to_list(Node))] ++
case Res of
ok -> [?CT("Submitted"), ?P];
error -> [?CT("Bad format"), ?P];
nothing -> []
end ++
[?XAE("form", [{"action", ""}, {"method", "post"}],
[?INPUTT("submit", "update", "Update"),
?XCT("h2", "Update plan"),
?XCT("h3", "Updated modules"), Mods,
?XCT("h3", "Update script"), FmtScript,
?XCT("h3", "Low level update script"), FmtLowLevelScript,
?XCT("h3", "Script check"), ?C(atom_to_list(Check))])
];
get_node(Host, Node, NPath, Query, Lang) ->
[?XCT("h1", "Not Found")].
@ -2331,6 +2364,22 @@ node_modules_parse_query(Host, Node, Modules, Query) ->
end.
node_update_parse_query(Node, Query) ->
case lists:keysearch("update", 1, Query) of
{value, _} ->
case rpc:call(Node, ejabberd_update, update, []) of
{ok, _} ->
ok;
{error, Error} ->
?ERROR_MSG("~p~n", [Error]);
{badrpc, Error} ->
?ERROR_MSG("~p~n", [Error])
end;
_ ->
nothing
end.
pretty_print(El) ->
lists:flatten(pretty_print(El, "")).