[Box Backup-commit] COMMIT r3320 - box/trunk/bin/bbackupctl
subversion at boxbackup.org
subversion at boxbackup.org
Wed Apr 9 23:15:39 BST 2014
Author: chris
Date: 2014-04-09 23:15:39 +0100 (Wed, 09 Apr 2014)
New Revision: 3320
Modified:
box/trunk/bin/bbackupctl/bbackupctl.cpp
Log:
Add a status command to bbackupctl.
Allows polling the daemon to see if it's running, without telling it to
actually do anything.
Modified: box/trunk/bin/bbackupctl/bbackupctl.cpp
===================================================================
--- box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-04-09 22:15:36 UTC (rev 3319)
+++ box/trunk/bin/bbackupctl/bbackupctl.cpp 2014-04-09 22:15:39 UTC (rev 3320)
@@ -38,6 +38,7 @@
WaitForSyncStart,
WaitForSyncEnd,
SyncAndWaitForEnd,
+ NoCommand,
};
void PrintUsageAndExit()
@@ -44,6 +45,7 @@
{
printf("Usage: bbackupctl [-q] [-c config_file] <command>\n"
"Commands are:\n"
+ " status -- report daemon status without changing anything\n"
" sync -- start a synchronisation (backup) run now\n"
" force-sync -- force the start of a synchronisation run, "
"even if SyncAllowScript says no\n"
@@ -230,6 +232,11 @@
{
command = SyncAndWaitForEnd;
}
+ else if (commandName == "status")
+ {
+ BOX_NOTICE("state " << currentState);
+ command = NoCommand;
+ }
switch (command)
{
@@ -269,10 +276,18 @@
{
// Normal case, just send the command given
// plus a quit command.
- std::string cmd = commandName;
- cmd += "\nquit\n";
+ std::string cmd = commandName + "\n";
connection.Write(cmd.c_str(), cmd.size());
}
+ // fall through
+
+ case NoCommand:
+ {
+ // Normal case, just send the command given
+ // plus a quit command.
+ std::string cmd = "quit\n";
+ connection.Write(cmd.c_str(), cmd.size());
+ }
}
// Read the response
@@ -280,7 +295,7 @@
bool syncIsRunning = false;
bool finished = false;
- while(!finished && !getLine.IsEOF() && getLine.GetLine(line))
+ while(command != NoCommand && !finished && !getLine.IsEOF() && getLine.GetLine(line))
{
switch (command)
{
More information about the Boxbackup-commit
mailing list