arisa 2.1.4 → 2.1.6
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 +35 -13
- package/package.json +1 -1
package/bin/arisa.js
CHANGED
|
@@ -417,6 +417,13 @@ function isProvisioned() {
|
|
|
417
417
|
return arisaUserExists() && existsSync("/home/arisa/.bun/bin/bun");
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
+
function isArisaConfigured() {
|
|
421
|
+
const envPath = "/home/arisa/.arisa/.env";
|
|
422
|
+
if (!existsSync(envPath)) return false;
|
|
423
|
+
const content = readFileSync(envPath, "utf8");
|
|
424
|
+
return content.includes("TELEGRAM_BOT_TOKEN=");
|
|
425
|
+
}
|
|
426
|
+
|
|
420
427
|
function detectSudoGroup() {
|
|
421
428
|
// Debian/Ubuntu use 'sudo', RHEL/Fedora use 'wheel'
|
|
422
429
|
const sudoGroup = spawnSync("getent", ["group", "sudo"], { stdio: "ignore" });
|
|
@@ -568,7 +575,7 @@ if (isRoot()) {
|
|
|
568
575
|
step(true, "Systemd service enabled (auto-starts on reboot)");
|
|
569
576
|
|
|
570
577
|
process.stdout.write("\nStarting interactive setup as user arisa...\n\n");
|
|
571
|
-
const su = spawnSync("su", ["-", "arisa", "-c", "arisa"], {
|
|
578
|
+
const su = spawnSync("su", ["-", "arisa", "-c", "/home/arisa/.bun/bin/arisa"], {
|
|
572
579
|
stdio: "inherit",
|
|
573
580
|
});
|
|
574
581
|
|
|
@@ -593,6 +600,30 @@ Arisa management:
|
|
|
593
600
|
process.exit(0);
|
|
594
601
|
}
|
|
595
602
|
|
|
603
|
+
// No args → interactive setup if not configured, otherwise systemd
|
|
604
|
+
if (isDefaultInvocation) {
|
|
605
|
+
if (!isArisaConfigured()) {
|
|
606
|
+
process.stdout.write("Arisa is not configured yet. Starting interactive setup...\n\n");
|
|
607
|
+
const su = spawnSync("su", ["-", "arisa", "-c", "/home/arisa/.bun/bin/arisa"], {
|
|
608
|
+
stdio: "inherit",
|
|
609
|
+
});
|
|
610
|
+
process.stdout.write(`
|
|
611
|
+
Arisa management:
|
|
612
|
+
Start: systemctl start arisa
|
|
613
|
+
Status: systemctl status arisa
|
|
614
|
+
Logs: journalctl -u arisa -f
|
|
615
|
+
Restart: systemctl restart arisa
|
|
616
|
+
Stop: systemctl stop arisa
|
|
617
|
+
`);
|
|
618
|
+
process.exit(su.status ?? 0);
|
|
619
|
+
}
|
|
620
|
+
if (isSystemdActive()) {
|
|
621
|
+
process.exit(statusSystemdSystem());
|
|
622
|
+
} else {
|
|
623
|
+
process.exit(startSystemdSystem());
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
|
|
596
627
|
switch (command) {
|
|
597
628
|
case "start":
|
|
598
629
|
process.exit(startSystemdSystem());
|
|
@@ -608,25 +639,16 @@ Arisa management:
|
|
|
608
639
|
break;
|
|
609
640
|
case "daemon":
|
|
610
641
|
case "run": {
|
|
611
|
-
//
|
|
612
|
-
const su = spawnSync("su", ["-", "arisa", "-c", "arisa"], {
|
|
642
|
+
// Explicit "arisa daemon/run" → foreground as arisa user
|
|
643
|
+
const su = spawnSync("su", ["-", "arisa", "-c", "/home/arisa/.bun/bin/arisa"], {
|
|
613
644
|
stdio: "inherit",
|
|
614
645
|
});
|
|
615
646
|
process.exit(su.status ?? 1);
|
|
616
647
|
}
|
|
617
|
-
default:
|
|
618
|
-
// No args or unknown — start if not active, otherwise show status
|
|
619
|
-
if (isDefaultInvocation) {
|
|
620
|
-
if (isSystemdActive()) {
|
|
621
|
-
process.exit(statusSystemdSystem());
|
|
622
|
-
} else {
|
|
623
|
-
process.exit(startSystemdSystem());
|
|
624
|
-
}
|
|
625
|
-
}
|
|
648
|
+
default:
|
|
626
649
|
process.stderr.write(`Unknown command: ${command}\n\n`);
|
|
627
650
|
printHelp();
|
|
628
651
|
process.exit(1);
|
|
629
|
-
}
|
|
630
652
|
}
|
|
631
653
|
}
|
|
632
654
|
|