define-alpine-the-sequel/index.ts

51 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-01-16 15:14:20 +00:00
import { mkdir, mkdtemp } from "node:fs/promises";
2023-01-16 12:42:10 +00:00
import { tmpdir } from "node:os";
import path from "node:path";
2023-01-16 15:14:20 +00:00
import { Alpine } from "./alpine.js";
import { spawn } from "./helpers.js";
import { Runit } from "./runit/index.js";
2023-01-16 12:42:10 +00:00
{
const rootfsDir = await mkdtemp(path.join(tmpdir(), "define-alpine-"));
console.debug(rootfsDir);
2023-01-16 15:14:20 +00:00
const alpine = await Alpine.makeWorld({ dir: rootfsDir });
const runit = await Runit.setup(alpine);
// await makeService({
// parentDir: rootfsDir,
// name: "grafana",
// packages: ["grafana"],
// setup: async (dir) => {},
// initScript: async (dir) => {},
// });
2023-01-16 12:42:10 +00:00
try {
await spawn("sudo", ["chroot", rootfsDir], { stdio: "inherit" });
} catch {}
}
2023-01-16 15:14:20 +00:00
// interface Service {}
// async function makeService({
// parentDir,
// name,
// packages,
// setup,
// initScript: _initScript,
// }: {
// parentDir: string;
// name: string;
// packages?: string[];
// setup: (dir: string) => Promise<void>;
// initScript: (dir: string) => Promise<string>;
// }) {
// const rootsDir = path.join(parentDir, "/nulo/roots/");
// await mkdir(rootsDir, { recursive: true });
2023-01-16 12:42:10 +00:00
2023-01-16 15:14:20 +00:00
// const alpine = await Alpine.makeWorld({
// dir: path.join(rootsDir, name),
// packages,
// });
2023-01-16 12:42:10 +00:00
2023-01-16 15:14:20 +00:00
// await setup(alpine.dir);
// // const initScript = await _initScript(rootfsDir);
// }