fix: dual-mode installer — works with or without sudo

Installer now detects at runtime if it can get root access:
- Root/NOPASSWD sudo: installs to system directories with systemd
- No root: installs to ~/.local/bin with @reboot cron job

Self-elevation uses 'script -qc sudo bash' for requiretty, or falls
back to user mode without hanging on password prompts.

Uninstaller checks both system and user paths.
This commit is contained in:
2026-06-11 19:12:57 -04:00
parent 0edc882f2e
commit fd3cc6825c
3 changed files with 94 additions and 67 deletions

View File

@@ -68,7 +68,6 @@ class AgentService
$output = trim($result['output']);
$exitStatus = $result['exit_status'] ?? -1;
$path = '/usr/local/bin/servermanager-agent';
if ($exitStatus !== 0) {
$lastLines = implode("\n", array_slice(explode("\n", $output), -20));
@@ -79,6 +78,11 @@ class AgentService
];
}
$path = '/usr/local/bin/servermanager-agent';
if (preg_match('/Binary:\s*(\S+)/', $output, $m)) {
$path = $m[1];
}
$serverModel = new \ServerManager\Models\Server();
$serverModel->setAgentInstalled($serverId, true, $path);