mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: auto create config folder and player network
This commit is contained in:
1 parent
91ebaec22c
commit
b449d84c54
5 files changed
+25
-2
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import ssh2 from 'ssh2'
|
||||
|
||||
const {
|
||||
@@ -17,6 +18,10 @@ export function loadOrCreateKeyPair(privateKeyPath: string): KeyPair {
|
||||
const publicKey = fs.readFileSync(publicKeyPath, 'utf8')
|
||||
return { privateKey, publicKey }
|
||||
}
|
||||
const dir = path.dirname(privateKeyPath)
|
||||
if (!fs.existsSync(dir)) {
|
||||
fs.mkdirSync(dir, { recursive: true })
|
||||
}
|
||||
const keyPair = generateKeyPair()
|
||||
fs.writeFileSync(privateKeyPath, keyPair.privateKey, {
|
||||
mode: 0o600,
|
||||
|
||||
Reference in new issue
Block a user