mirror of
https://github.com/outbackdingo/sysadm.git
synced 2026-01-27 18:20:23 +00:00
Add two new API calls, to shutdown/halt the system, and to
reboot the system.
Shutdown API call
REST Request:
-------------------------------
PUT /sysadm/systemmanager
{
"action" : "halt"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"args" : {
"action" : "halt"
},
"name" : "systemmanager",
"namespace" : "sysadm"
}
Response:
-------------------------------
{
"args": {
"halt": {
"response": "true"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
Reboot API call
REST Request:
-------------------------------
PUT /sysadm/systemmanager
{
"action" : "reboot"
}
WebSocket Request:
-------------------------------
{
"id" : "fooid",
"args" : {
"action" : "reboot"
},
"name" : "systemmanager",
"namespace" : "sysadm"
}
Response:
-------------------------------
{
"args": {
"reboot": {
"response": "true"
}
},
"id": "fooid",
"name": "response",
"namespace": "sysadm"
}
This commit is contained in:
@@ -405,6 +405,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmSystemMgmtRequest(const QJso
|
||||
ok = true;
|
||||
out->insert("externalmounts", sysadm::SysMgmt::externalDevicePaths());
|
||||
}
|
||||
if(act=="halt"){
|
||||
ok = true;
|
||||
out->insert("halt", sysadm::SysMgmt::systemHalt());
|
||||
}
|
||||
if(act=="killproc"){
|
||||
ok = true;
|
||||
out->insert("killproc", sysadm::SysMgmt::killProc(in_args.toObject()));
|
||||
@@ -417,6 +421,10 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmSystemMgmtRequest(const QJso
|
||||
ok = true;
|
||||
out->insert("procinfo", sysadm::SysMgmt::procInfo());
|
||||
}
|
||||
if(act=="reboot"){
|
||||
ok = true;
|
||||
out->insert("reboot", sysadm::SysMgmt::systemReboot());
|
||||
}
|
||||
if(act=="setsysctl"){
|
||||
ok = true;
|
||||
out->insert("setsysctl", sysadm::SysMgmt::setSysctl(in_args.toObject()));
|
||||
|
||||
@@ -371,3 +371,23 @@ QJsonObject SysMgmt::systemInfo() {
|
||||
return retObject;
|
||||
}
|
||||
|
||||
// Halt the box
|
||||
QJsonObject SysMgmt::systemHalt() {
|
||||
QJsonObject retObject;
|
||||
|
||||
QString output = General::RunCommand("shutdown -p now");
|
||||
retObject.insert("response", "true");
|
||||
|
||||
return retObject;
|
||||
}
|
||||
|
||||
|
||||
// Reboot the box
|
||||
QJsonObject SysMgmt::systemReboot() {
|
||||
QJsonObject retObject;
|
||||
|
||||
QString output = General::RunCommand("shutdown -r now");
|
||||
retObject.insert("response", "true");
|
||||
|
||||
return retObject;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@ public:
|
||||
static QJsonObject setSysctl(QJsonObject);
|
||||
static QJsonObject sysctlList();
|
||||
static QJsonObject systemInfo();
|
||||
static QJsonObject systemReboot();
|
||||
static QJsonObject systemHalt();
|
||||
};
|
||||
|
||||
} //end of pcbsd namespace
|
||||
|
||||
Reference in New Issue
Block a user