arisa 2.2.10 → 2.2.11
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/bin/arisa.js +37 -0
- package/package.json +1 -1
package/bin/arisa.js
CHANGED
|
@@ -448,9 +448,46 @@ function runAsInherit(cmd) {
|
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
450
|
|
|
451
|
+
function ensureSwap() {
|
|
452
|
+
// Check if swap already exists
|
|
453
|
+
const swapon = spawnSync("swapon", ["--show"], { stdio: "pipe" });
|
|
454
|
+
const swapOutput = (swapon.stdout || "").toString().trim();
|
|
455
|
+
if (swapOutput.includes("/")) return; // swap already active
|
|
456
|
+
|
|
457
|
+
// Create 512MB swap file (essential on 1GB VPS for bun add)
|
|
458
|
+
process.stdout.write(" Creating swap file (512MB)...\n");
|
|
459
|
+
const cmds = [
|
|
460
|
+
["fallocate", ["-l", "512M", "/swapfile"]],
|
|
461
|
+
["chmod", ["600", "/swapfile"]],
|
|
462
|
+
["mkswap", ["/swapfile"]],
|
|
463
|
+
["swapon", ["/swapfile"]],
|
|
464
|
+
];
|
|
465
|
+
for (const [cmd, cmdArgs] of cmds) {
|
|
466
|
+
const result = spawnSync(cmd, cmdArgs, { stdio: "pipe" });
|
|
467
|
+
if (result.status !== 0) {
|
|
468
|
+
step(false, "Failed to create swap file");
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// Make persistent across reboots
|
|
474
|
+
const fstabPath = "/etc/fstab";
|
|
475
|
+
if (existsSync(fstabPath)) {
|
|
476
|
+
const fstab = readFileSync(fstabPath, "utf8");
|
|
477
|
+
if (!fstab.includes("/swapfile")) {
|
|
478
|
+
writeFileSync(fstabPath, fstab.trimEnd() + "\n/swapfile none swap sw 0 0\n");
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
step(true, "Swap file created (512MB)");
|
|
483
|
+
}
|
|
484
|
+
|
|
451
485
|
function provisionArisaUser() {
|
|
452
486
|
process.stdout.write("Running as root \u2014 creating dedicated user 'arisa'...\n");
|
|
453
487
|
|
|
488
|
+
// 0. Ensure swap exists (prevents OOM on 1GB VPS during CLI installs)
|
|
489
|
+
ensureSwap();
|
|
490
|
+
|
|
454
491
|
// 1. Create user
|
|
455
492
|
const useradd = spawnSync("useradd", ["-m", "-s", "/bin/bash", "arisa"], {
|
|
456
493
|
stdio: "pipe",
|