diff --git a/logic/system.ts b/logic/system.ts index ba6b915..1fea04d 100644 --- a/logic/system.ts +++ b/logic/system.ts @@ -418,3 +418,7 @@ export async function requestReboot(): Promise { throw new Error('Unable to request reboot'); } } + +export async function setUpdateChannel(channel: string): Promise { + return runCommand(`set-update-channel ${channel}`); +} diff --git a/routes/v2/system.ts b/routes/v2/system.ts index a4d6bf2..4e2c9bb 100644 --- a/routes/v2/system.ts +++ b/routes/v2/system.ts @@ -1,5 +1,5 @@ import Router from '@koa/router'; -import {errorHandler} from '@runcitadel/utils'; +import {errorHandler, typeHelper} from '@runcitadel/utils'; import * as systemLogic from '../../logic/system.js'; import * as diskLogic from '../../logic/disk.js'; @@ -143,6 +143,12 @@ router.get('/disk-type', async (ctx, next) => { await next(); }); +router.put('/update-channel', async (ctx, next) => { + typeHelper.isString(ctx.body.channel, ctx); + await systemLogic.setUpdateChannel(ctx.body.channel as string); + await next(); +}); + router.get('/', async (ctx, next) => { ctx.body = {os: constants.IS_CITADEL_OS ? 'Citadel OS' : 'unknown'}; await next();