feat: show install command on machine creation

This commit is contained in:
xboard
2026-04-17 06:47:05 +08:00
parent e297b5fe9f
commit a74cc2f19d
4 changed files with 7 additions and 6 deletions
@@ -72,6 +72,7 @@ class MachineController extends Controller
return $this->success([
'id' => $machine->id,
'token' => $machine->token,
'install_command' => $this->buildInstallCommand($request, $machine),
]);
}
@@ -191,12 +192,12 @@ class MachineController extends Controller
private function buildInstallCommand(Request $request, ServerMachine $machine): string
{
$panelUrl = rtrim((string) (config('app.url') ?: $request->getSchemeAndHttpHost()), '/');
$panelUrl = rtrim((string) (admin_setting('app_url') ?: $request->getSchemeAndHttpHost()), '/');
$installerUrl = 'https://raw.githubusercontent.com/cedar2025/xboard-node/main/install.sh';
return sprintf(
'bash <(curl -fsSL %s) --panel %s --token %s --machine-id %d --yes',
escapeshellarg($installerUrl),
'curl -fsSL %s | sudo bash -s -- --mode machine --panel %s --token %s --machine-id %d',
$installerUrl,
escapeshellarg($panelUrl),
escapeshellarg($machine->token),
$machine->id
@@ -17,7 +17,7 @@ class ManageController extends Controller
public function getNodes(Request $request)
{
$servers = ServerService::getAllServers()->map(function ($item) {
$item['groups'] = ServerGroup::whereIn('id', $item['group_ids'])->get(['name', 'id']);
$item['groups'] = ServerGroup::whereIn('id', $item['group_ids'] ?? [])->get(['name', 'id']);
$item['parent'] = $item->parent;
return $item;
});