mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 10:20:26 +00:00
Add a new API call: sysadm/pkg, "action"="pkg_install".
This will install the given packages on the system.
Required arguments:
"pkg_origins" = (single origin string or array of origin strings).
Optional arguments:
"repo": Name of the remote repository to use (if not supplied, pkg will automatically determine repository).
NOTE: The actual information will be returned as a Dispatcher event - this API call just queues up the pkg operation (limitation of pkg - only one process call at a time)
REST Request:
-------------------------------
PUT /sysadm/pkg
{
"pkg_origins" : "games/angband",
"action" : "pkg_install",
"repo" : "pcbsd-major"
}
WebSocket Request:
-------------------------------
{
"name" : "pkg",
"namespace" : "sysadm",
"id" : "fooid",
"args" : {
"action" : "pkg_install",
"pkg_origins" : "games/angband",
"repo" : "pcbsd-major"
}
}
Response:
-------------------------------
{
"args": {
"pkg_install": {
"proc_cmd": "pkg install -y --repository \"pcbsd-major\" games/angband",
"proc_id": "sysadm_pkg_install-{ae444472-47df-4a65-91eb-013cc82ce4ad}",
"status": "pending"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -711,7 +711,9 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmPkgRequest(const QJsonValue
|
||||
|
||||
//Parse the action and perform accordingly
|
||||
if(act=="pkg_info"){
|
||||
//OPTIONAL: "result"
|
||||
//OPTIONAL: "pkg_origins" OR "category"
|
||||
//OPTIONAL: "repo"
|
||||
//OPTIONAL: "result" = "full" or "simple" (Default: "simple")
|
||||
bool fullresults = false;
|
||||
if(in_args.toObject().contains("result")){ fullresults = (in_args.toObject().value("result").toString()=="full"); }
|
||||
|
||||
@@ -720,10 +722,11 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmPkgRequest(const QJsonValue
|
||||
if(!info.isEmpty()){ out->insert("pkg_info",info); }
|
||||
else{ return RestOutputStruct::NOCONTENT; }
|
||||
|
||||
}else if(act=="pkg_search"){
|
||||
//REQUIRED
|
||||
QString srch;
|
||||
if(in_args.toObject().contains("search_term")){ srch = in_args.toObject().value("search_term").toString(); }
|
||||
}else if(act=="pkg_search" && in_args.toObject().contains("search_term")){
|
||||
//REQUIRED: "search_term" (string to search for)
|
||||
//OPTIONAL: "repo"
|
||||
//OPTIONAL: "category"
|
||||
QString srch = in_args.toObject().value("search_term").toString();
|
||||
if(srch.isEmpty()){ return RestOutputStruct::BADREQUEST; }
|
||||
QStringList pkgs = sysadm::PKG::pkg_search(repo, srch, cat);
|
||||
if(!pkgs.isEmpty()){
|
||||
@@ -734,6 +737,7 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmPkgRequest(const QJsonValue
|
||||
}
|
||||
|
||||
}else if(act=="list_categories"){
|
||||
//OPTIONAL: "repo"
|
||||
QJsonArray cats = sysadm::PKG::list_categories(repo);
|
||||
if(!cats.isEmpty()){ out->insert("list_categories", cats); }
|
||||
else{ return RestOutputStruct::NOCONTENT; }
|
||||
@@ -745,10 +749,14 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmPkgRequest(const QJsonValue
|
||||
|
||||
}else if(act=="pkg_install" && !pkgs.isEmpty() ){
|
||||
//REQUIRED: "pkg_origins"
|
||||
|
||||
}else if(act=="pkg_remove" && !pkgs.isEmpty() ){
|
||||
//OPTIONAL: "repo" (pkg will determine the best repo to use if not supplied)
|
||||
out->insert("pkg_install", sysadm::PKG::pkg_install(pkgs,repo));
|
||||
/*}else if(act=="pkg_remove" && !pkgs.isEmpty() ){
|
||||
//REQUIRED: "pkg_origins"
|
||||
|
||||
//OPTIONAL: "recursive"="true" or "false" (default: "true")
|
||||
bool recursive = true;
|
||||
if(in_args.toObject().contains("recursive")){ recursive = in_args.toObject().value("recursive").toString()=="false"; }
|
||||
out->insert("pkg_remove", sysadm::PKG::pkg_remove(pkgs, recursive));*/
|
||||
}else if(act=="pkg_lock" && !pkgs.isEmpty() ){
|
||||
//REQUIRED: "pkg_origins"
|
||||
out->insert("pkg_lock", sysadm::PKG::pkg_lock(pkgs));
|
||||
|
||||
Reference in New Issue
Block a user