mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Write the config file on restart and shutdown
ZNC now writes its config file just before it shuts down. If this fails it aborts the shutdown. One can then either fix whatever went wrong or force a shutdown. This also cleans the code up a little by unifying shutdown and restart. Patch by flakes, thanks! git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1641 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -204,24 +204,27 @@ void CClient::UserCommand(CString& sLine) {
|
||||
PutStatus("Cleared MOTD");
|
||||
} else if (m_pUser->IsAdmin() && sCommand.Equals("BROADCAST")) {
|
||||
CZNC::Get().Broadcast(sLine.Token(1, true));
|
||||
} else if (m_pUser->IsAdmin() && sCommand.Equals("SHUTDOWN")) {
|
||||
} else if (m_pUser->IsAdmin() && (sCommand.Equals("SHUTDOWN") || sCommand.Equals("RESTART"))) {
|
||||
bool bRestart = sCommand.Equals("RESTART");
|
||||
CString sMessage = sLine.Token(1, true);
|
||||
bool bForce = false;
|
||||
|
||||
if (sMessage.empty()) {
|
||||
sMessage = "ZNC is being shutdown NOW!!";
|
||||
if (sMessage.Token(0).Equals("FORCE")) {
|
||||
bForce = true;
|
||||
sMessage = sMessage.Token(1, true);
|
||||
}
|
||||
|
||||
CZNC::Get().Broadcast(sMessage);
|
||||
throw CException(CException::EX_Shutdown);
|
||||
} else if (m_pUser->IsAdmin() && sCommand.Equals("RESTART")) {
|
||||
CString sMessage = sLine.Token(1, true);
|
||||
|
||||
if (sMessage.empty()) {
|
||||
sMessage = "ZNC is being restarted NOW!!";
|
||||
sMessage = (bRestart ? "ZNC is being restarted NOW!" : "ZNC is being shut down NOW!");
|
||||
}
|
||||
|
||||
CZNC::Get().Broadcast(sMessage);
|
||||
throw CException(CException::EX_Restart);
|
||||
if(!CZNC::Get().WriteConfig() && !bForce) {
|
||||
PutStatus("ERROR: Writing config file to disk failed! Aborting. Use " +
|
||||
sCommand.AsUpper() + " FORCE to ignore.");
|
||||
} else {
|
||||
CZNC::Get().Broadcast(sMessage);
|
||||
throw CException(bRestart ? CException::EX_Restart : CException::EX_Shutdown);
|
||||
}
|
||||
} else if (sCommand.Equals("JUMP") || sCommand.Equals("CONNECT")) {
|
||||
if (!m_pUser->HasServers()) {
|
||||
PutStatus("You don't have any servers added.");
|
||||
|
||||
Reference in New Issue
Block a user