initial commit
This commit is contained in:
34
src/index.ts
Normal file
34
src/index.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import { getMqttClient } from "./clients/mqtt/mqtt-client";
|
||||
import { ConfigSchema } from "./config.schema";
|
||||
import { EfiBootMgrService } from "./efibootmgr.service";
|
||||
import { startListeners } from "./listener";
|
||||
import { logger } from "./logger";
|
||||
import { runPublishLoop } from "./publisher";
|
||||
|
||||
logger.info("Starting intialization...");
|
||||
|
||||
const configsFolder = process.env.CONFIGS_PATH || "./";
|
||||
|
||||
const fileContent = await readFile(
|
||||
join(configsFolder, "efibootmgr.config.json"),
|
||||
{
|
||||
encoding: "utf8",
|
||||
},
|
||||
).catch((e) => {
|
||||
throw new Error("Error while reading config!", { cause: e });
|
||||
});
|
||||
|
||||
const json = JSON.parse(fileContent);
|
||||
|
||||
const config = ConfigSchema.parse(json);
|
||||
|
||||
const efiBootMgrService = new EfiBootMgrService();
|
||||
|
||||
const bootEntries = await efiBootMgrService.listBootEntries();
|
||||
|
||||
const mqttClient = await getMqttClient(config.mqtt);
|
||||
|
||||
runPublishLoop(config, mqttClient, bootEntries);
|
||||
startListeners(config, mqttClient);
|
||||
Reference in New Issue
Block a user