mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 02:20:17 +00:00
API CHANGE: Add a new "stopupdate" action for the sysadm/update class. (no additional inputs required).
This will look for any currently-running pc-updatemanager processes and kill/stop them as needed.
Example:
{
"id":"dummy",
"namespace":"sysadm",
"name":"update",
"args": {
"action":"stopupdate"
}
}
Output arguments:
"args":{
"stopupdate":{
"result":"success" or "error:<error text>"
}
}
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user