From 9f057b6941fa77d8021ec99230689941c77193b3 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Mon, 28 Oct 2019 17:21:30 +0000 Subject: [server/configloader] Add a better (dynamic) default config, delete the old default config & eslint fix --- server/api/configloader.js | 7 ++----- server/api/registration.js | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'server/api') diff --git a/server/api/configloader.js b/server/api/configloader.js index f6c4597..ba395d0 100644 --- a/server/api/configloader.js +++ b/server/api/configloader.js @@ -8,8 +8,6 @@ const config = require(path.join(__appdir, 'config', 'config')) const url = config.https.host + ':' + config.https.port const configHelper = require(path.join(__appdir, 'lib', 'confighelper')) - - noAuthRouter.getAsync(['/test/group/:id', '/test/group/'], async (req, res) => { const list = req.query.list !== undefined && req.query.list !== 'false' const config = await configHelper.getGroupConfig(req.params.id, list) @@ -22,7 +20,6 @@ noAuthRouter.getAsync(['/test/group/:id', '/test/group/'], async (req, res) => { } }) - noAuthRouter.getAsync(['/test/:uuid', '/test/'], async (req, res) => { const list = req.query.list !== undefined && req.query.list !== 'false' const config = await configHelper.getConfig(req.params.uuid, list) @@ -34,7 +31,6 @@ noAuthRouter.getAsync(['/test/:uuid', '/test/'], async (req, res) => { } }) - // if client in db -> load script (default if none is found), else load registration script noAuthRouter.getAsync('/:uuid', async (req, res) => { const uuid = req.params.uuid @@ -128,7 +124,8 @@ noAuthRouter.getAsync('/:uuid', async (req, res) => { if (client.configId !== null) return res.send(await createIpxeScript(client.configId)) } // No config found, use default config - await sendFilePromise(res, path.join(__appdir, 'ipxe', 'default.ipxe')) + // await sendFilePromise(res, path.join(__appdir, 'ipxe', 'default.ipxe')) + res.send(await configHelper.getDefaultConfig(client)) }) // load config by given id diff --git a/server/api/registration.js b/server/api/registration.js index 9064846..156ec21 100644 --- a/server/api/registration.js +++ b/server/api/registration.js @@ -232,7 +232,7 @@ noAuthRouter.postAsync('/clients', async (req, res) => { // Add the client to the backends. const result = backendHelper.addClient(client) if (ipxe) return res.send(`#!ipxe\nsleep 5\nchain https://` + url + `/api/configloader/\${uuid}`) - else return res.send(result) + else return res.send(await result) }) noAuthRouter.postAsync('/clients/:uuid', async (req, res) => { -- cgit v1.2.3-55-g7522