ramm 0.0.14 → 0.0.15
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 +22 -0
- package/dist/types/cron.d.ts +4 -0
- package/dist/types/ramm.d.ts +1 -0
- package/package.json +1 -1
package/dist/ramm.js
CHANGED
|
@@ -339,6 +339,27 @@ var createAndAddSshKey = async (pathToKey, comment, context) => {
|
|
|
339
339
|
debug(`Key is: ${pubKey}`);
|
|
340
340
|
await addSshKey(pubKey, context);
|
|
341
341
|
};
|
|
342
|
+
// src/cron.ts
|
|
343
|
+
var createCron = async ({
|
|
344
|
+
time,
|
|
345
|
+
pathToFile
|
|
346
|
+
}) => {
|
|
347
|
+
const constructedLine = `${time} ${pathToFile}`;
|
|
348
|
+
const tempFile = `/tmp/cron_${new Date().getTime().toString()}`;
|
|
349
|
+
const { output: cronConfig } = await execCommand("crontab -l");
|
|
350
|
+
let newCronConfig = cronConfig;
|
|
351
|
+
if (cronConfig.includes(constructedLine)) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (cronConfig.includes(pathToFile)) {
|
|
355
|
+
newCronConfig = cronConfig.split(`
|
|
356
|
+
`).filter((str) => !str.includes(pathToFile)).join(`
|
|
357
|
+
`);
|
|
358
|
+
}
|
|
359
|
+
await writeFile(tempFile, newCronConfig);
|
|
360
|
+
await execCommand(`crontab ${tempFile}`);
|
|
361
|
+
await execCommand(`rm ${tempFile}`);
|
|
362
|
+
};
|
|
342
363
|
export {
|
|
343
364
|
writeIfNew,
|
|
344
365
|
writeFile,
|
|
@@ -354,6 +375,7 @@ export {
|
|
|
354
375
|
execCommand,
|
|
355
376
|
execBySsh,
|
|
356
377
|
debugBlock,
|
|
378
|
+
createCron,
|
|
357
379
|
createAndAddSshKey,
|
|
358
380
|
copyFilesBySsh,
|
|
359
381
|
addNftPodmanRule,
|
package/dist/types/ramm.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export { setupNftable } from "./nft.ts";
|
|
|
10
10
|
export { writeIfNew, writeFile } from "./files.ts";
|
|
11
11
|
export { createAndAddSshKey, getServerFingerprintBySsh, addKeyToHostConfig, } from "./ssh.ts";
|
|
12
12
|
export { normalizePath } from "./path.ts";
|
|
13
|
+
export { createCron } from "./cron.ts";
|
package/package.json
CHANGED