ramm 0.0.26 → 0.0.28

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 CHANGED
@@ -247,10 +247,7 @@ var createNftTable = ({ allowedIpV4 }) => {
247
247
  var setupNftable = async ({
248
248
  allowedIpV4
249
249
  }) => {
250
- const listTable = await execCommand("nft list table inet ramm");
251
- if (listTable.spawnResult.exitCode === 0) {
252
- await execCommand("nft delete table inet ramm");
253
- }
250
+ await execCommand("nft flush ruleset");
254
251
  const nftTable = createNftTable({ allowedIpV4 });
255
252
  await execCommand(`nft -f - <<EOF
256
253
  ${nftTable}
@@ -384,6 +381,17 @@ var createAndAddSshKey = async (pathToKey, comment, context) => {
384
381
  debug(`Key is: ${pubKey}`);
385
382
  await addSshKeyToAuthorized(pubKey, context);
386
383
  };
384
+ var setupSshKey = async ({
385
+ key,
386
+ fingerprint,
387
+ pathToFile,
388
+ server
389
+ }) => {
390
+ await writeIfNewCompletely(pathToFile, key);
391
+ await execCommand(`chmod 0600 ${pathToFile}`);
392
+ await writeIfNew("~/.ssh/known_hosts", fingerprint);
393
+ await addKeyToHostConfig("~/.ssh/config", server, pathToFile);
394
+ };
387
395
  // src/cron.ts
388
396
  var createCron = async ({
389
397
  time,
@@ -446,6 +454,7 @@ export {
446
454
  writeIfNew,
447
455
  writeIfNewCompletely as writeFileIfNotMatch,
448
456
  writeFile,
457
+ setupSshKey,
449
458
  setupNftable,
450
459
  runPodmanContainerService,
451
460
  runPodmanContainer,
@@ -8,7 +8,7 @@ export { installSystemPackage } from "./packages.ts";
8
8
  export { debugBlock } from "./debug.ts";
9
9
  export { setupNftable } from "./nft.ts";
10
10
  export { writeIfNew, writeFile, writeIfNewCompletely as writeFileIfNotMatch, normalizeFileContent, } from "./files.ts";
11
- export { createAndAddSshKey, getServerFingerprintBySsh, addKeyToHostConfig, } from "./ssh.ts";
11
+ export { createAndAddSshKey, getServerFingerprintBySsh, addKeyToHostConfig, setupSshKey, } from "./ssh.ts";
12
12
  export { normalizePath } from "./path.ts";
13
13
  export { createCron } from "./cron.ts";
14
14
  export { buildAndRunOverSsh, passVarsClient, passVarsServer } from "./build.ts";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ramm",
3
3
  "type": "module",
4
- "version": "0.0.26",
4
+ "version": "0.0.28",
5
5
  "scripts": {
6
6
  "build": "bun build ./src/ramm.ts --target bun --outdir ./dist && cp ./src/bun.sh ./dist/bun.sh",
7
7
  "types": "tsc --project tsconfig.types.json"