ramm 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ramm.js +35 -0
- package/dist/types/files.d.ts +1 -0
- package/dist/types/ramm.d.ts +2 -1
- package/dist/types/ssh.d.ts +1 -1
- package/package.json +1 -1
package/dist/ramm.js
CHANGED
|
@@ -216,8 +216,41 @@ var addNftPodmanRule = async () => {
|
|
|
216
216
|
await execCommand("nft add chain inet ramm forward '{ type filter hook forward priority 0 ; }'");
|
|
217
217
|
await execCommand(`nft add rule inet ramm forward iifname != @podman_interfaces jump ${localNftChainName}`);
|
|
218
218
|
};
|
|
219
|
+
// src/files.ts
|
|
220
|
+
import { appendFile } from "fs/promises";
|
|
221
|
+
var finalizeWithNewline = (str) => {
|
|
222
|
+
if (str.at(-1) !== `
|
|
223
|
+
`) {
|
|
224
|
+
return str + `
|
|
225
|
+
`;
|
|
226
|
+
}
|
|
227
|
+
return str;
|
|
228
|
+
};
|
|
229
|
+
var checkStrInFile = async (filePath, str) => {
|
|
230
|
+
const file = Bun.file(filePath);
|
|
231
|
+
if (!await file.exists()) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
const fileText = await file.text();
|
|
235
|
+
if (fileText.includes(str)) {
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
return false;
|
|
239
|
+
};
|
|
240
|
+
var writeIfNew = async (filePath, str) => {
|
|
241
|
+
if (await checkStrInFile(filePath, str)) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
await appendFile(filePath, finalizeWithNewline(str));
|
|
245
|
+
};
|
|
219
246
|
// src/ssh.ts
|
|
220
247
|
import { debug } from "console";
|
|
248
|
+
var addKeyToHostConfig = async (address, pathToKey) => {
|
|
249
|
+
const text = `Host ${address}
|
|
250
|
+
IdentityFile ${pathToKey}
|
|
251
|
+
`;
|
|
252
|
+
await writeIfNew(pathToKey, text);
|
|
253
|
+
};
|
|
221
254
|
var getServerFingerprintBySsh = async (context) => {
|
|
222
255
|
const { output } = await execBySsh('ssh-keyscan -t ed25519 localhost | grep -v "^#"', context);
|
|
223
256
|
return output.replace("localhost", context.domain);
|
|
@@ -250,6 +283,7 @@ var createAndAddSshKey = async (pathToKey, comment, context) => {
|
|
|
250
283
|
await addSshKey(pubKey, context);
|
|
251
284
|
};
|
|
252
285
|
export {
|
|
286
|
+
writeIfNew,
|
|
253
287
|
setupNftable,
|
|
254
288
|
runPodmanContainerService,
|
|
255
289
|
runPodmanContainer,
|
|
@@ -264,5 +298,6 @@ export {
|
|
|
264
298
|
createAndAddSshKey,
|
|
265
299
|
copyFilesBySsh,
|
|
266
300
|
addNftPodmanRule,
|
|
301
|
+
addKeyToHostConfig,
|
|
267
302
|
Context
|
|
268
303
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const writeIfNew: (filePath: string, str: string) => Promise<void>;
|
package/dist/types/ramm.d.ts
CHANGED
|
@@ -7,4 +7,5 @@ export { restartSystemdService } from "./systemd.ts";
|
|
|
7
7
|
export { installSystemPackage } from "./packages.ts";
|
|
8
8
|
export { debugBlock } from "./debug.ts";
|
|
9
9
|
export { setupNftable } from "./nft.ts";
|
|
10
|
-
export {
|
|
10
|
+
export { writeIfNew } from "./files.ts";
|
|
11
|
+
export { createAndAddSshKey, getServerFingerprintBySsh, addKeyToHostConfig, } from "./ssh.ts";
|
package/dist/types/ssh.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Context } from "./context.ts";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const addKeyToHostConfig: (address: string, pathToKey: string) => Promise<void>;
|
|
3
3
|
export declare const getServerFingerprintBySsh: (context: Context) => Promise<string>;
|
|
4
4
|
export declare const createAndAddSshKey: (pathToKey: string, comment: string, context: Context) => Promise<void>;
|
package/package.json
CHANGED