|
|
import fs from "node:fs"; |
|
|
import os from "node:os"; |
|
|
import path from "node:path"; |
|
|
import { execAsync, paths } from "@dokploy/server"; |
|
|
|
|
|
export const getShell = () => { |
|
|
switch (os.platform()) { |
|
|
case "win32": |
|
|
return "powershell.exe"; |
|
|
case "darwin": |
|
|
return "zsh"; |
|
|
default: |
|
|
return "bash"; |
|
|
} |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export const setupLocalServerSSHKey = async () => { |
|
|
const { SSH_PATH } = paths(true); |
|
|
const sshKeyPath = path.join(SSH_PATH, "auto_generated-dokploy-local"); |
|
|
|
|
|
if (!fs.existsSync(sshKeyPath)) { |
|
|
|
|
|
await execAsync( |
|
|
`ssh-keygen -t rsa -b 4096 -f ${sshKeyPath} -N "" -C "dokploy-local-access"`, |
|
|
); |
|
|
} |
|
|
|
|
|
const privateKey = fs.readFileSync(sshKeyPath, "utf8"); |
|
|
|
|
|
return privateKey; |
|
|
}; |
|
|
|