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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user