From cf8cf0d42987a84391dc28e1115986741e3ac1ff Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 21 Mar 2016 13:08:13 -0400 Subject: [PATCH] Add a "updaterunning" status to the sysadm/update check for updates, and also setup sysadm/update to emit dispatcher events about the update process. --- src/server/DispatcherParsing.cpp | 8 +++++++- src/server/library/sysadm-update.cpp | 10 ++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/server/DispatcherParsing.cpp b/src/server/DispatcherParsing.cpp index 070fa4f..49c04f1 100644 --- a/src/server/DispatcherParsing.cpp +++ b/src/server/DispatcherParsing.cpp @@ -29,6 +29,7 @@ QJsonObject Dispatcher::CreateDispatcherEventNotification(QString ID, QJsonObjec //Now parse the notification based on the dispatch ID or current command //NOTE: There might be a random string on the end of the ID (to accomodate similar process calls) + // == sysadm/iohyve == if(ID.startsWith("sysadm_iohyve")){ namesp = "sysadm"; name="iohyve"; //Now perform additional cmd/system based filtering @@ -36,7 +37,12 @@ QJsonObject Dispatcher::CreateDispatcherEventNotification(QString ID, QJsonObjec //Do some parsing of the log parseIohyveFetchOutput(cLog,&args); } - + + // == sysadm/update == + }else if(ID.startsWith("sysadm_update")){ + namesp = "sysadm"; name="update"; + //No special parsing here: the pc-updatemanager output should be available as-is + args.insert("update_log",cLog); } //Now assemble the output as needed diff --git a/src/server/library/sysadm-update.cpp b/src/server/library/sysadm-update.cpp index 81e1510..eb9abe3 100644 --- a/src/server/library/sysadm-update.cpp +++ b/src/server/library/sysadm-update.cpp @@ -21,7 +21,13 @@ QJsonObject Update::checkUpdates() { retObject.insert("status","rebootrequired"); return retObject; } - + if(QFile::exists("/tmp/.updateInProgress")){ + //See if the process is actually running + if( 0==General::RunCommand("pgrep -F /tmp/.updateInProgress") ){ + retObject.insert("status","updaterunning"); + return retObject; + } + } QStringList output = General::RunCommand("pc-updatemanager check").split("\n"); QString nameval; int pnum=1; @@ -148,7 +154,7 @@ QJsonObject Update::startUpdate(QJsonObject jsin) { QString ID = QUuid::createUuid().toString(); // Queue the update action - DISPATCHER->queueProcess(ID, "pc-updatemanager " + flags); + DISPATCHER->queueProcess("sysadm_update_runupdates::"+ID, "pc-updatemanager " + flags); // Return some details to user that the action was queued retObject.insert("command", "pc-updatemanger " + flags);