summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2014-04-09 22:15:39 +0000
committerChris Wilson <chris+github@qwirx.com>2014-04-09 22:15:39 +0000
commit5e16bd3a7e4ce829d9daca45ce3d69cadd1caf9f (patch)
tree0f3e142f25fe362508ab07fcb27db191d8e13632 /bin
parent3b324ca62004b8ed56c3cba3ebdf61ef97b66324 (diff)
Add a status command to bbackupctl.
Allows polling the daemon to see if it's running, without telling it to actually do anything.
Diffstat (limited to 'bin')
-rw-r--r--bin/bbackupctl/bbackupctl.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/bin/bbackupctl/bbackupctl.cpp b/bin/bbackupctl/bbackupctl.cpp
index 643f0e8c..69dd7215 100644
--- a/bin/bbackupctl/bbackupctl.cpp
+++ b/bin/bbackupctl/bbackupctl.cpp
@@ -38,12 +38,14 @@ enum Command
WaitForSyncStart,
WaitForSyncEnd,
SyncAndWaitForEnd,
+ NoCommand,
};
void PrintUsageAndExit()
{
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 @@ int main(int argc, const char *argv[])
{
command = SyncAndWaitForEnd;
}
+ else if (commandName == "status")
+ {
+ BOX_NOTICE("state " << currentState);
+ command = NoCommand;
+ }
switch (command)
{
@@ -269,8 +276,16 @@ int main(int argc, const char *argv[])
{
// 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());
}
}
@@ -280,7 +295,7 @@ int main(int argc, const char *argv[])
bool syncIsRunning = false;
bool finished = false;
- while(!finished && !getLine.IsEOF() && getLine.GetLine(line))
+ while(command != NoCommand && !finished && !getLine.IsEOF() && getLine.GetLine(line))
{
switch (command)
{