2017-11-26 18:43:51 -05:00
|
|
|
/***********************************************************************************************************************************
|
|
|
|
Main
|
|
|
|
***********************************************************************************************************************************/
|
2017-11-28 21:44:05 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2018-01-17 15:52:00 -05:00
|
|
|
#include "command/archive/push/push.h"
|
2018-01-23 13:34:24 -05:00
|
|
|
#include "command/help/help.h"
|
2017-11-28 21:44:05 -05:00
|
|
|
#include "common/error.h"
|
2018-01-17 09:15:51 -05:00
|
|
|
#include "common/exit.h"
|
2017-11-28 21:44:05 -05:00
|
|
|
#include "config/config.h"
|
2018-01-16 13:52:20 -05:00
|
|
|
#include "config/load.h"
|
2017-11-26 18:43:51 -05:00
|
|
|
#include "perl/exec.h"
|
2017-11-28 21:44:05 -05:00
|
|
|
#include "version.h"
|
2017-11-26 18:43:51 -05:00
|
|
|
|
2018-01-31 18:22:25 -05:00
|
|
|
int
|
|
|
|
main(int argListSize, const char *argList[])
|
2017-11-26 18:43:51 -05:00
|
|
|
{
|
2018-02-18 15:45:32 -05:00
|
|
|
bool error = false;
|
|
|
|
|
2017-11-28 21:44:05 -05:00
|
|
|
TRY_BEGIN()
|
|
|
|
{
|
2018-01-16 13:52:20 -05:00
|
|
|
// Load the configuration
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2018-03-02 12:07:12 -05:00
|
|
|
cfgLoad((unsigned int)argListSize, argList);
|
2017-11-28 21:44:05 -05:00
|
|
|
|
2018-01-23 13:34:24 -05:00
|
|
|
// Display help
|
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
|
|
|
if (cfgCommandHelp())
|
|
|
|
{
|
|
|
|
cmdHelp();
|
|
|
|
}
|
|
|
|
|
2017-11-28 21:44:05 -05:00
|
|
|
// Display version
|
2018-01-16 13:52:20 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2018-02-18 15:45:32 -05:00
|
|
|
else if (cfgCommand() == cfgCmdVersion)
|
2017-11-28 21:44:05 -05:00
|
|
|
{
|
|
|
|
printf(PGBACKREST_NAME " " PGBACKREST_VERSION "\n");
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2018-02-05 12:41:42 -05:00
|
|
|
// Archive push command. Currently only implements local operations of async archive push.
|
2018-01-17 15:52:00 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2018-02-18 15:45:32 -05:00
|
|
|
else if (cfgCommand() == cfgCmdArchivePush && cfgOptionBool(cfgOptArchiveAsync))
|
2018-01-17 15:52:00 -05:00
|
|
|
{
|
|
|
|
cmdArchivePush();
|
|
|
|
}
|
|
|
|
|
2017-11-28 21:44:05 -05:00
|
|
|
// Execute Perl for commands not implemented in C
|
2018-01-17 09:15:51 -05:00
|
|
|
// -------------------------------------------------------------------------------------------------------------------------
|
2018-02-18 15:45:32 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
perlExec();
|
|
|
|
}
|
2017-11-28 21:44:05 -05:00
|
|
|
}
|
|
|
|
CATCH_ANY()
|
|
|
|
{
|
2018-02-18 15:45:32 -05:00
|
|
|
error = true;
|
2017-11-28 21:44:05 -05:00
|
|
|
}
|
|
|
|
TRY_END();
|
2018-01-17 09:15:51 -05:00
|
|
|
|
2018-02-18 15:45:32 -05:00
|
|
|
return exitSafe(error);
|
2017-11-26 18:43:51 -05:00
|
|
|
}
|