first implementation for sync-tool
This commit is contained in:
parent
39b5551e90
commit
3573279dfa
@ -26,11 +26,69 @@ int main(int argc, char **argv) {
|
|||||||
QCoreApplication::setApplicationName("ATBUpdateSync");
|
QCoreApplication::setApplicationName("ATBUpdateSync");
|
||||||
QCoreApplication::setApplicationVersion(APP_VERSION);
|
QCoreApplication::setApplicationVersion(APP_VERSION);
|
||||||
|
|
||||||
|
QDebug debug = qCritical();
|
||||||
|
|
||||||
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
if (!messageHandlerInstalled()) { // change internal qt-QDebug-handling
|
||||||
atbInstallMessageHandler(nullptr);
|
atbInstallMessageHandler(nullptr);
|
||||||
//atbInstallMessageHandler(atbDebugOutput);
|
//atbInstallMessageHandler(atbDebugOutput);
|
||||||
setDebugLevel(LOG_NOTICE);
|
setDebugLevel(LOG_NOTICE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
if (internal::customerRepoExists() == false) {
|
||||||
|
qCritical().noquote() << internal::NO_CUSTOMER_REPOSITORY;
|
||||||
|
return internal::NO_CUSTOMER_REPOSITORY_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString const crd = internal::customerRepoDir();
|
||||||
|
QString const etcInRepo = QDir::cleanPath(crd + QDir::separator() + "etc/");
|
||||||
|
QString const optInRepo = QDir::cleanPath(crd + QDir::separator() + "opt/");
|
||||||
|
|
||||||
|
if (!QDir(etcInRepo).exists()) {
|
||||||
|
qCritical().noquote() << internal::NO_ETC_CUSTOMER_REPOSITORY;
|
||||||
|
return internal::NO_ETC_CUSTOMER_REPOSITORY_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!QDir(optInRepo).exists()) {
|
||||||
|
qCritical().noquote() << internal::NO_OPT_CUSTOMER_REPOSITORY;
|
||||||
|
return internal::NO_OPT_CUSTOMER_REPOSITORY_CODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
error codes for rsync:
|
||||||
|
https://stackoverflow.com/questions/20737204/comprehensive-list-of-rsync-error-codes
|
||||||
|
|
||||||
|
0 Success
|
||||||
|
1 Syntax or usage error
|
||||||
|
2 Protocol incompatibility
|
||||||
|
3 Errors selecting input/output files, dirs
|
||||||
|
4 Requested action not supported: an attempt was made to manipulate 64-bit
|
||||||
|
files on a platform that cannot support them; or an option was specified
|
||||||
|
that is supported by the client and not by the server.
|
||||||
|
5 Error starting client-server protocol
|
||||||
|
6 Daemon unable to append to log-file
|
||||||
|
10 Error in socket I/O
|
||||||
|
11 Error in file I/O
|
||||||
|
12 Error in rsync protocol data stream
|
||||||
|
13 Errors with program diagnostics
|
||||||
|
14 Error in IPC code
|
||||||
|
20 Received SIGUSR1 or SIGINT
|
||||||
|
21 Some error returned by waitpid()
|
||||||
|
22 Error allocating core memory buffers
|
||||||
|
23 Partial transfer due to error
|
||||||
|
24 Partial transfer due to vanished source files
|
||||||
|
25 The --max-delete limit stopped deletions
|
||||||
|
30 Timeout in data send/receive
|
||||||
|
35 Timeout waiting for daemon connection
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
QStringList options({"-v", "--recursive", "--progress", "--checksum",
|
||||||
|
"--exclude=.*", "--include=*.bin", "--include=*.json",
|
||||||
|
"--include=*.ini"});
|
||||||
|
int ret = SyncCommand().exec("rsync", options << etcInRepo << "/etc");
|
||||||
|
|
||||||
|
if (ret == 0) {
|
||||||
|
ret = SyncCommand().exec("rsync", options << optInRepo << "/opt");
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,10 @@ using namespace internal;
|
|||||||
SyncCommand::SyncCommand() {
|
SyncCommand::SyncCommand() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SyncCommand::exec(QString const &cmd, QStringList const &options,
|
int SyncCommand::exec(QString const &cmd, QStringList const &options,
|
||||||
int start_timeout, int finish_timeout) {
|
int start_timeout, int finish_timeout) {
|
||||||
return false;
|
Command c(cmd, options, internal::customerRepoDir(),
|
||||||
|
start_timeout, finish_timeout);
|
||||||
|
c.exec();
|
||||||
|
return c.exitCode();
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ class SyncCommand {
|
|||||||
public:
|
public:
|
||||||
SyncCommand();
|
SyncCommand();
|
||||||
|
|
||||||
bool exec(QString const &cmd, QStringList const &options,
|
int exec(QString const &cmd, QStringList const &options,
|
||||||
int start_timeout = 100000, int finish_timeout = 100000);
|
int start_timeout = 100000, int finish_timeout = 100000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user