complete handling of reboot
This commit is contained in:
@@ -8,7 +8,7 @@ export class EfiBootMgrService {
|
|||||||
await $`reboot`;
|
await $`reboot`;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setNextBoot(bootNum: string) {
|
async setNextBoot(bootNum: number) {
|
||||||
await $`efibootmgr -n ${bootNum}`;
|
await $`efibootmgr -n ${bootNum}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
/** biome-ignore-all lint/style/noNonNullAssertion: we are checking if boot entry is undefined */
|
||||||
import type { MqttClient } from "mqtt";
|
import type { MqttClient } from "mqtt";
|
||||||
import type z from "zod";
|
import type z from "zod";
|
||||||
import type { ConfigSchema } from "./config.schema";
|
import type { ConfigSchema } from "./config.schema";
|
||||||
import type { BootEntries } from "./efibootmgr.schema";
|
import type { BootEntries } from "./efibootmgr.schema";
|
||||||
|
import { EfiBootMgrService } from "./efibootmgr.service";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
|
|
||||||
export async function startListeners(
|
export async function startListeners(
|
||||||
@@ -11,6 +13,8 @@ export async function startListeners(
|
|||||||
) {
|
) {
|
||||||
await mqttClient.subscribeAsync(`efibootmgr-mqtt/${config.device.key}/+`);
|
await mqttClient.subscribeAsync(`efibootmgr-mqtt/${config.device.key}/+`);
|
||||||
|
|
||||||
|
const efiBootMgrService = new EfiBootMgrService();
|
||||||
|
|
||||||
mqttClient.on("message", async (topic, payload) => {
|
mqttClient.on("message", async (topic, payload) => {
|
||||||
logger.info(topic, payload.toString());
|
logger.info(topic, payload.toString());
|
||||||
|
|
||||||
@@ -30,7 +34,11 @@ export async function startListeners(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Rebooting into: ${bootEntry?.label}`);
|
logger.info(`Rebooting into: ${bootEntry!.label}`);
|
||||||
|
|
||||||
|
await efiBootMgrService.setNextBoot(bootEntry!.number);
|
||||||
|
|
||||||
|
await efiBootMgrService.reboot();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user