Anope IRC Services  Version 2.0
os_shutdown.cpp
Go to the documentation of this file.
1 /* OperServ core functions
2  *
3  * (C) 2003-2014 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 CommandOSQuit : public Command
15 {
16  public:
17  CommandOSQuit(Module *creator) : Command(creator, "operserv/quit", 0, 0)
18  {
19  this->SetDesc(_("Terminate Services WITHOUT saving"));
20  }
21 
22  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
23  {
24  Log(LOG_ADMIN, source, this);
25  Anope::QuitReason = source.command + " command received from " + source.GetNick();
26  Anope::Quitting = true;
27  return;
28  }
29 
30  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
31  {
32  this->SendSyntax(source);
33  source.Reply(" ");
34  source.Reply(_("Causes Services to do an immediate shutdown; databases are\n"
35  "\002not\002 saved. This command should not be used unless\n"
36  "damage to the in-memory copies of the databases is feared\n"
37  "and they should not be saved."));
38  return true;
39  }
40 };
41 
42 class CommandOSRestart : public Command
43 {
44  public:
45  CommandOSRestart(Module *creator) : Command(creator, "operserv/restart", 0, 0)
46  {
47  this->SetDesc(_("Save databases and restart Services"));
48  }
49 
50  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
51  {
52  Log(LOG_ADMIN, source, this);
53  Anope::QuitReason = source.command + " command received from " + source.GetNick();
56  return;
57  }
58 
59  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
60  {
61  this->SendSyntax(source);
62  source.Reply(_("Causes Services to save all databases and then restart\n"
63  "(i.e. exit and immediately re-run the executable)."));
64  return true;
65  }
66 };
67 
68 class CommandOSShutdown : public Command
69 {
70  public:
71  CommandOSShutdown(Module *creator) : Command(creator, "operserv/shutdown", 0, 0)
72  {
73  this->SetDesc(_("Terminate services with save"));
74  }
75 
76  void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
77  {
78  Log(LOG_ADMIN, source, this);
79  Anope::QuitReason = source.command + " command received from " + source.GetNick();
80  Anope::Quitting = true;
82  return;
83  }
84 
85  bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
86  {
87  this->SendSyntax(source);
88  source.Reply(" ");
89  source.Reply(_("Causes Services to save all databases and then shut down."));
90  return true;
91  }
92 };
93 
94 class OSShutdown : public Module
95 {
99 
100  public:
101  OSShutdown(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR),
102  commandosquit(this), commandosrestart(this), commandosshutdown(this)
103  {
104 
105  }
106 };
107 
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: os_shutdown.cpp:76
CoreExport bool Restarting
Definition: main.cpp:35
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: os_shutdown.cpp:85
void SetDesc(const Anope::string &d)
Definition: command.cpp:130
CommandOSShutdown commandosshutdown
Definition: os_shutdown.cpp:98
CommandOSRestart commandosrestart
Definition: os_shutdown.cpp:97
CoreExport bool Quitting
Definition: main.cpp:34
OSShutdown(const Anope::string &modname, const Anope::string &creator)
#define anope_override
Definition: services.h:56
CommandOSRestart(Module *creator)
Definition: os_shutdown.cpp:45
#define MODULE_INIT(x)
Definition: modules.h:45
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: os_shutdown.cpp:50
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: os_shutdown.cpp:59
CommandOSShutdown(Module *creator)
Definition: os_shutdown.cpp:71
void Execute(CommandSource &source, const std::vector< Anope::string > &params) anope_override
Definition: os_shutdown.cpp:22
void SendSyntax(CommandSource &)
Definition: command.cpp:145
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
Definition: os_shutdown.cpp:30
Definition: logger.h:53
CommandOSQuit commandosquit
Definition: os_shutdown.cpp:96
CoreExport void SaveDatabases()
Definition: main.cpp:67
#define _(x)
Definition: services.h:50
CoreExport Anope::string QuitReason
Definition: main.cpp:36
CommandOSQuit(Module *creator)
Definition: os_shutdown.cpp:17