diff --git a/src/server/WebBackend.cpp b/src/server/WebBackend.cpp index 0280174..46ff23a 100644 --- a/src/server/WebBackend.cpp +++ b/src/server/WebBackend.cpp @@ -581,6 +581,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmUpdateRequest(const QJsonVal }else if(act=="startupdate"){ ok = true; out->insert("startupdate", sysadm::Update::startUpdate(in_args.toObject()) ); + + }else if(act=="stopupdate"){ + ok = true; + out->insert("stopupdate", sysadm::Update::stopUpdate() ); } } //end of "action" key usage diff --git a/src/server/library/sysadm-update.cpp b/src/server/library/sysadm-update.cpp index cdde30a..482284a 100644 --- a/src/server/library/sysadm-update.cpp +++ b/src/server/library/sysadm-update.cpp @@ -190,3 +190,27 @@ QJsonObject Update::startUpdate(QJsonObject jsin) { retObject.insert("queueid", ID); return retObject; } + +// Stop an update process +QJsonObject Update::stopUpdate() { + //See if the update is running in the dispatcher + QJsonObject ret; + QJsonObject cup = DISPATCHER->listJobs(); + QStringList ids = cup.keys().filter("sysadm_update_runupdates::"); + if(!ids.isEmpty()){ + //Found a dispatcher process - go ahead and request that it stop + DISPATCHER->killJobs(ids); + ret.insert("result","success"); + }else if( QFile::exists(UP_PIDFILE) ){ + //See if the process is actually running + if( General::RunQuickCommand(QString("pgrep -F ")+UP_PIDFILE) ){ + //Success if return code == 0 + int rtc = General::RunQuickCommand( QString("pkill -F ")+UP_PIDFILE ); + if(rtc==0){ ret.insert("result","success"); } + else{ ret.insert("result","error: could not kill update process"); } + } + }else{ + ret.insert("result","error: no update processes found"); + } + return ret; +} diff --git a/src/server/library/sysadm-update.h b/src/server/library/sysadm-update.h index 8f6ddb3..0dfbdee 100644 --- a/src/server/library/sysadm-update.h +++ b/src/server/library/sysadm-update.h @@ -16,7 +16,10 @@ class Update{ public: static QJsonObject checkUpdates(bool fast = false); static QJsonObject listBranches(); + //Start/stop update routine static QJsonObject startUpdate(QJsonObject); + static QJsonObject stopUpdate(); + }; } //end of pcbsd namespace