Added flag for maintenance-mode

This commit is contained in:
Gerhard Hoffmann 2023-06-20 16:08:42 +02:00
parent bbf97dc58d
commit 079a6910dd

View File

@ -35,9 +35,10 @@
#endif #endif
class hwinf; class hwinf;
static void doWork(hwinf *hw, QString update_ctrl_file, QString workingDir) { static void doWork(hwinf *hw, QString update_ctrl_file,
QString workingDir, bool maintenanceMode) {
std::this_thread::sleep_for(std::chrono::milliseconds(2000)); std::this_thread::sleep_for(std::chrono::milliseconds(2000));
Update update(hw, update_ctrl_file, workingDir); Update update(hw, update_ctrl_file, workingDir, maintenanceMode);
update.doUpdate(); update.doUpdate();
std::this_thread::sleep_for(std::chrono::milliseconds(2000)); std::this_thread::sleep_for(std::chrono::milliseconds(2000));
QCoreApplication::quit(); QCoreApplication::quit();
@ -87,11 +88,16 @@ int main(int argc, char *argv[]) {
workingDirectoryOption.setDefaultValue(workingDirectoryDefault); workingDirectoryOption.setDefaultValue(workingDirectoryDefault);
parser.addOption(workingDirectoryOption); parser.addOption(workingDirectoryOption);
QCommandLineOption maintenanceOption("m",
QCoreApplication::translate("main", "Maintenance mode for underlying script"));
parser.addOption(maintenanceOption);
// Process the actual command line arguments given by the user // Process the actual command line arguments given by the user
parser.process(a); parser.process(a);
QString plugInDir = parser.value(pluginDirectoryOption); QString plugInDir = parser.value(pluginDirectoryOption);
QString plugInName = parser.value(pluginNameOption); QString plugInName = parser.value(pluginNameOption);
QString workingDir = parser.value(workingDirectoryOption); QString workingDir = parser.value(workingDirectoryOption);
bool maintenanceMode = parser.isSet(maintenanceOption);
QString const rtPath = QCoreApplication::applicationDirPath(); QString const rtPath = QCoreApplication::applicationDirPath();
if (plugInDir == pluginDefault) { if (plugInDir == pluginDefault) {
@ -106,6 +112,7 @@ int main(int argc, char *argv[]) {
qInfo() << "plugInDir" << "=" << plugInDir; qInfo() << "plugInDir" << "=" << plugInDir;
qInfo() << "plugInName" << "=" << plugInName; qInfo() << "plugInName" << "=" << plugInName;
qInfo() << "workingDir" << "=" << workingDir; qInfo() << "workingDir" << "=" << workingDir;
qInfo() << "maintenanceMode" << "=" << maintenanceMode;
// before loading the library, delete all possible shared memory segments // before loading the library, delete all possible shared memory segments
#if defined Q_OS_LINUX || defined Q_OS_UNIX #if defined Q_OS_LINUX || defined Q_OS_UNIX
@ -118,7 +125,7 @@ int main(int argc, char *argv[]) {
hw->dc_autoRequest(false); hw->dc_autoRequest(false);
QString const update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv"; QString const update_ctrl_file = "/opt/app/tools/atbupdate/update_log.csv";
std::thread t(doWork, hw, update_ctrl_file, workingDir); std::thread t(doWork, hw, update_ctrl_file, workingDir, maintenanceMode);
int ret = a.exec(); int ret = a.exec();
t.join(); t.join();