anope

- supernets anope source code & configuration
git clone git://git.acid.vegas/anope.git
Log | Files | Refs | Archive | README

os_reload.cpp (1716B)

      1 /* OperServ core functions
      2  *
      3  * (C) 2003-2022 Anope Team
      4  * Contact us at team@anope.org
      5  *
      6  * Please read COPYING and README for further details.
      7  *
      8  * Based on the original code of Epona by Lara.
      9  * Based on the original code of Services by Andy Church.
     10  */
     11 
     12 #include "module.h"
     13 
     14 class CommandOSReload : public Command
     15 {
     16  public:
     17 	CommandOSReload(Module *creator) : Command(creator, "operserv/reload", 0, 0)
     18 	{
     19 		this->SetDesc(_("Reload services' configuration file"));
     20 	}
     21 
     22 	void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
     23 	{
     24 		try
     25 		{
     26 			Log(LOG_ADMIN, source, this);
     27 
     28 			Configuration::Conf *new_config = new Configuration::Conf();
     29 			Configuration::Conf *old = Config;
     30 			Config = new_config;
     31 			Config->Post(old);
     32 			delete old;
     33 
     34 			source.Reply(_("Services' configuration has been reloaded."));
     35 		}
     36 		catch (const ConfigException &ex)
     37 		{
     38 			Log(this->owner) << "Error reloading configuration file: " << ex.GetReason();
     39 			source.Reply(_("Error reloading configuration file: %s"), ex.GetReason().c_str());
     40 		}
     41 	}
     42 
     43 	bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
     44 	{
     45 		this->SendSyntax(source);
     46 		source.Reply(" ");
     47 		source.Reply(_("Causes Services to reload the configuration file. Note that\n"
     48 				"some directives still need the restart of the Services to\n"
     49 				"take effect (such as Services' nicknames, activation of the\n"
     50 				"session limitation, etc.)."));
     51 		return true;
     52 	}
     53 };
     54 
     55 class OSReload : public Module
     56 {
     57 	CommandOSReload commandosreload;
     58 
     59  public:
     60 	OSReload(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
     61 		commandosreload(this)
     62 	{
     63 
     64 	}
     65 };
     66 
     67 MODULE_INIT(OSReload)