* 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:
parent
51c4ab8351
commit
20d049fe28
|
@ -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>
|
2006-02-25 Alexey Shchepin <alexey@sevcom.net>
|
||||||
|
|
||||||
* src/msgs/ru.msg: Updated (thanks to Sergei Golovan)
|
* src/msgs/ru.msg: Updated (thanks to Sergei Golovan)
|
||||||
|
|
|
@ -10,12 +10,25 @@
|
||||||
-author('alexey@sevcom.net').
|
-author('alexey@sevcom.net').
|
||||||
|
|
||||||
%% API
|
%% API
|
||||||
-export([update/0]).
|
-export([update/0, update_info/0]).
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
update() ->
|
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)),
|
Dir = filename:dirname(code:which(ejabberd)),
|
||||||
case file:list_dir(Dir) of
|
case file:list_dir(Dir) of
|
||||||
{ok, Files} ->
|
{ok, Files} ->
|
||||||
|
@ -46,11 +59,7 @@ update() ->
|
||||||
LowLevelScript,
|
LowLevelScript,
|
||||||
[{ejabberd, "", filename:join(Dir, "..")}]),
|
[{ejabberd, "", filename:join(Dir, "..")}]),
|
||||||
io:format("check: ~p~n", [Check]),
|
io:format("check: ~p~n", [Check]),
|
||||||
Eval =
|
{ok, Dir, UpdatedBeams, Script, LowLevelScript, Check};
|
||||||
release_handler_1:eval_script(
|
|
||||||
LowLevelScript, [],
|
|
||||||
[{ejabberd, "", filename:join(Dir, "..")}]),
|
|
||||||
io:format("eval: ~p~n", [Eval]);
|
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -1841,7 +1841,8 @@ get_node(global, Node, [], Query, Lang) ->
|
||||||
[?LI([?ACT("db/", "Database")]),
|
[?LI([?ACT("db/", "Database")]),
|
||||||
?LI([?ACT("backup/", "Backup")]),
|
?LI([?ACT("backup/", "Backup")]),
|
||||||
?LI([?ACT("ports/", "Listened Ports")]),
|
?LI([?ACT("ports/", "Listened Ports")]),
|
||||||
?LI([?ACT("stats/", "Statistics")])
|
?LI([?ACT("stats/", "Statistics")]),
|
||||||
|
?LI([?ACT("update/", "Update")])
|
||||||
]),
|
]),
|
||||||
?XAE("form", [{"action", ""}, {"method", "post"}],
|
?XAE("form", [{"action", ""}, {"method", "post"}],
|
||||||
[?INPUTT("submit", "restart", "Restart"),
|
[?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) ->
|
get_node(Host, Node, NPath, Query, Lang) ->
|
||||||
[?XCT("h1", "Not Found")].
|
[?XCT("h1", "Not Found")].
|
||||||
|
|
||||||
|
@ -2331,6 +2364,22 @@ node_modules_parse_query(Host, Node, Modules, Query) ->
|
||||||
end.
|
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) ->
|
pretty_print(El) ->
|
||||||
lists:flatten(pretty_print(El, "")).
|
lists:flatten(pretty_print(El, "")).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue