Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/file-server/zfs/util.ts
1447 views
1
import { executeCode } from "@cocalc/backend/execute-code";
2
import { context, DEFAULT_EXEC_TIMEOUT_MS } from "./config";
3
import { fatalError } from "./db";
4
5
export async function exec(opts) {
6
try {
7
return await executeCode({
8
...opts,
9
timeout: DEFAULT_EXEC_TIMEOUT_MS / 1000,
10
});
11
} catch (err) {
12
if (opts.what) {
13
fatalError({
14
...opts.what,
15
err,
16
desc: `${opts.desc ? opts.desc : ""} "${opts.command} ${opts.args?.join(" ") ?? ""}"`,
17
});
18
}
19
throw err;
20
}
21
}
22
23
export async function initDataDir() {
24
await executeCode({ command: "sudo", args: ["mkdir", "-p", context.DATA] });
25
await executeCode({
26
command: "sudo",
27
args: ["chmod", "a+rxw", context.DATA],
28
});
29
}
30
31