Comparison

plugins/mod_admin_adhoc.lua @ 4292:894ffea639e9

mod_admin_adhoc: Add "Reload configuration" command
author Florian Zeitz <florob@babelmonkeys.de>
date Thu, 02 Jun 2011 21:56:44 +0200
parent 3778:bd1845f9d5a4
child 4296:b991ffa0f2c5
comparison
equal deleted inserted replaced
4291:122f142da281 4292:894ffea639e9
1 -- Copyright (C) 2009-2010 Florian Zeitz 1 -- Copyright (C) 2009-2011 Florian Zeitz
2 -- 2 --
3 -- This file is MIT/X11 licensed. Please see the 3 -- This file is MIT/X11 licensed. Please see the
4 -- COPYING file in the source package for more information. 4 -- COPYING file in the source package for more information.
5 -- 5 --
6 6
98 end 98 end
99 else 99 else
100 return { status = "executing", form = change_user_password_layout }, "executing"; 100 return { status = "executing", form = change_user_password_layout }, "executing";
101 end 101 end
102 end 102 end
103
104 function config_reload_handler(self, data, state)
105 local ok, err = prosody.reload_config();
106 if ok then
107 return { status = "completed", info = "Configuration reloaded (modules may need to be reloaded for this to have an effect)" };
108 else
109 return { status = "completed", error = { message = "Failed to reload config: " .. tostring(err) } };
110 end
111 end
112
103 113
104 function delete_user_command_handler(self, data, state) 114 function delete_user_command_handler(self, data, state)
105 local delete_user_layout = dataforms_new{ 115 local delete_user_layout = dataforms_new{
106 title = "Deleting a User"; 116 title = "Deleting a User";
107 instructions = "Fill out this form to delete a user."; 117 instructions = "Fill out this form to delete a user.";
538 548
539 return { status = "completed", info = "Server is about to shut down" }; 549 return { status = "completed", info = "Server is about to shut down" };
540 else 550 else
541 return { status = "executing", form = shut_down_service_layout }, "executing"; 551 return { status = "executing", form = shut_down_service_layout }, "executing";
542 end 552 end
543
544 return true;
545 end 553 end
546 554
547 function unload_modules_handler(self, data, state) 555 function unload_modules_handler(self, data, state)
548 local layout = dataforms_new { 556 local layout = dataforms_new {
549 title = "Unload modules"; 557 title = "Unload modules";
580 end 588 end
581 end 589 end
582 590
583 local add_user_desc = adhoc_new("Add User", "http://jabber.org/protocol/admin#add-user", add_user_command_handler, "admin"); 591 local add_user_desc = adhoc_new("Add User", "http://jabber.org/protocol/admin#add-user", add_user_command_handler, "admin");
584 local change_user_password_desc = adhoc_new("Change User Password", "http://jabber.org/protocol/admin#change-user-password", change_user_password_command_handler, "admin"); 592 local change_user_password_desc = adhoc_new("Change User Password", "http://jabber.org/protocol/admin#change-user-password", change_user_password_command_handler, "admin");
593 local config_reload_desc = adhoc_new("Reload configuration", "http://prosody.im/protocol/config#reload", config_reload_handler, "global_admin");
585 local delete_user_desc = adhoc_new("Delete User", "http://jabber.org/protocol/admin#delete-user", delete_user_command_handler, "admin"); 594 local delete_user_desc = adhoc_new("Delete User", "http://jabber.org/protocol/admin#delete-user", delete_user_command_handler, "admin");
586 local end_user_session_desc = adhoc_new("End User Session", "http://jabber.org/protocol/admin#end-user-session", end_user_session_handler, "admin"); 595 local end_user_session_desc = adhoc_new("End User Session", "http://jabber.org/protocol/admin#end-user-session", end_user_session_handler, "admin");
587 local get_user_password_desc = adhoc_new("Get User Password", "http://jabber.org/protocol/admin#get-user-password", get_user_password_handler, "admin"); 596 local get_user_password_desc = adhoc_new("Get User Password", "http://jabber.org/protocol/admin#get-user-password", get_user_password_handler, "admin");
588 local get_user_roster_desc = adhoc_new("Get User Roster","http://jabber.org/protocol/admin#get-user-roster", get_user_roster_handler, "admin"); 597 local get_user_roster_desc = adhoc_new("Get User Roster","http://jabber.org/protocol/admin#get-user-roster", get_user_roster_handler, "admin");
589 local get_user_stats_desc = adhoc_new("Get User Statistics","http://jabber.org/protocol/admin#user-stats", get_user_stats_handler, "admin"); 598 local get_user_stats_desc = adhoc_new("Get User Statistics","http://jabber.org/protocol/admin#user-stats", get_user_stats_handler, "admin");
594 local shut_down_service_desc = adhoc_new("Shut Down Service", "http://jabber.org/protocol/admin#shutdown", shut_down_service_handler, "admin"); 603 local shut_down_service_desc = adhoc_new("Shut Down Service", "http://jabber.org/protocol/admin#shutdown", shut_down_service_handler, "admin");
595 local unload_modules_desc = adhoc_new("Unload modules", "http://prosody.im/protocol/modules#unload", unload_modules_handler, "admin"); 604 local unload_modules_desc = adhoc_new("Unload modules", "http://prosody.im/protocol/modules#unload", unload_modules_handler, "admin");
596 605
597 module:add_item("adhoc", add_user_desc); 606 module:add_item("adhoc", add_user_desc);
598 module:add_item("adhoc", change_user_password_desc); 607 module:add_item("adhoc", change_user_password_desc);
608 module:add_item("adhoc", config_reload_desc);
599 module:add_item("adhoc", delete_user_desc); 609 module:add_item("adhoc", delete_user_desc);
600 module:add_item("adhoc", end_user_session_desc); 610 module:add_item("adhoc", end_user_session_desc);
601 module:add_item("adhoc", get_user_password_desc); 611 module:add_item("adhoc", get_user_password_desc);
602 module:add_item("adhoc", get_user_roster_desc); 612 module:add_item("adhoc", get_user_roster_desc);
603 module:add_item("adhoc", get_user_stats_desc); 613 module:add_item("adhoc", get_user_stats_desc);