plugins/mod_console.lua

changeset 1977
325a49f8edab
parent 1927
c3384860e23f
child 2007
b89d61db74d1
equal deleted inserted replaced
1976:5f3eaab987c3 1977:325a49f8edab
570 end 570 end
571 571
572 return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s"); 572 return true, "Closed "..count.." s2s session"..((count == 1 and "") or "s");
573 end 573 end
574 574
575 def_env.host = {}; def_env.hosts = def_env.host;
576 function def_env.host:activate(hostname, config)
577 local hostmanager_activate = require "core.hostmanager".activate;
578 if hosts[hostname] then
579 return false, "The host "..tostring(hostname).." is already activated";
580 end
581
582 local defined_hosts = config or configmanager.getconfig();
583 if not config and not defined_hosts[hostname] then
584 return false, "Couldn't find "..tostring(hostname).." defined in the config, perhaps you need to config:reload()?";
585 end
586 hostmanager_activate(hostname, config or defined_hosts[hostname]);
587 return true, "Host "..tostring(hostname).." activated";
588 end
589
590 function def_env.host:deactivate(hostname, reason)
591 local hostmanager_deactivate = require "core.hostmanager".deactivate;
592 local host = hosts[hostname];
593 if not host then
594 return false, "The host "..tostring(hostname).." is not activated";
595 end
596 if reason then
597 reason = { condition = "host-gone", text = reason };
598 end
599 hostmanager_deactivate(hostname, reason);
600 return true, "Host "..tostring(hostname).." deactivated";
601 end
602
575 ------------- 603 -------------
576 604
577 function printbanner(session) 605 function printbanner(session)
578 local option = config.get("*", "core", "console_banner"); 606 local option = config.get("*", "core", "console_banner");
579 if option == nil or option == "full" or option == "graphic" then 607 if option == nil or option == "full" or option == "graphic" then

mercurial