parent
00aa2c02df
commit
14a5b178dd
4 changed files with 37 additions and 2 deletions
@ -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…
Reference in new issue