fix(striker-ui-api): add PUT /update-system

main
Tsu-ba-me 2 years ago
parent 00aa2c02df
commit 14a5b178dd
  1. 1
      striker-ui-api/src/lib/consts/SERVER_PATHS.ts
  2. 1
      striker-ui-api/src/lib/request_handlers/command/index.ts
  3. 26
      striker-ui-api/src/lib/request_handlers/command/updateSystem.ts
  4. 11
      striker-ui-api/src/routes/command.ts

@ -21,6 +21,7 @@ const EMPTY_SERVER_PATHS: ServerPath = {
'anvil-manage-power': {}, 'anvil-manage-power': {},
'anvil-provision-server': {}, 'anvil-provision-server': {},
'anvil-sync-shared': {}, 'anvil-sync-shared': {},
'anvil-update-system': {},
'striker-manage-install-target': {}, 'striker-manage-install-target': {},
'striker-parse-os-list': {}, 'striker-parse-os-list': {},
}, },

@ -1,2 +1,3 @@
export * from './poweroffHost'; export * from './poweroffHost';
export * from './rebootHost'; export * from './rebootHost';
export * from './updateSystem';

@ -0,0 +1,26 @@
import { RequestHandler } from 'express';
import SERVER_PATHS from '../../consts/SERVER_PATHS';
import { job } from '../../accessModule';
import { stderr } from '../../shell';
export const updateSystem: RequestHandler = (request, response) => {
try {
job({
file: __filename,
job_command: SERVER_PATHS.usr.sbin['anvil-update-system'].self,
job_description: 'job_0004',
job_name: 'update::system',
job_title: 'job_0003',
});
} catch (subError) {
stderr(`Failed to initiate system update; CAUSE: ${subError}`);
response.status(500).send();
return;
}
response.status(204).send();
};

@ -1,9 +1,16 @@
import express from 'express'; import express from 'express';
import { poweroffHost, rebootHost } from '../lib/request_handlers/command'; import {
poweroffHost,
rebootHost,
updateSystem,
} from '../lib/request_handlers/command';
const router = express.Router(); const router = express.Router();
router.put('/poweroff-host', poweroffHost).put('/reboot-host', rebootHost); router
.put('/poweroff-host', poweroffHost)
.put('/reboot-host', rebootHost)
.put('/update-system', updateSystem);
export default router; export default router;

Loading…
Cancel
Save