mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-29 23:47:27 +08:00
feat: show install command on machine creation
This commit is contained in:
@@ -72,6 +72,7 @@ class MachineController extends Controller
|
|||||||
return $this->success([
|
return $this->success([
|
||||||
'id' => $machine->id,
|
'id' => $machine->id,
|
||||||
'token' => $machine->token,
|
'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
|
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';
|
$installerUrl = 'https://raw.githubusercontent.com/cedar2025/xboard-node/main/install.sh';
|
||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'bash <(curl -fsSL %s) --panel %s --token %s --machine-id %d --yes',
|
'curl -fsSL %s | sudo bash -s -- --mode machine --panel %s --token %s --machine-id %d',
|
||||||
escapeshellarg($installerUrl),
|
$installerUrl,
|
||||||
escapeshellarg($panelUrl),
|
escapeshellarg($panelUrl),
|
||||||
escapeshellarg($machine->token),
|
escapeshellarg($machine->token),
|
||||||
$machine->id
|
$machine->id
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ManageController extends Controller
|
|||||||
public function getNodes(Request $request)
|
public function getNodes(Request $request)
|
||||||
{
|
{
|
||||||
$servers = ServerService::getAllServers()->map(function ($item) {
|
$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;
|
$item['parent'] = $item->parent;
|
||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -429,7 +429,7 @@ class Server extends Model
|
|||||||
|
|
||||||
public function groups()
|
public function groups()
|
||||||
{
|
{
|
||||||
return ServerGroup::whereIn('id', $this->group_ids)->get();
|
return ServerGroup::whereIn('id', $this->group_ids ?? [])->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function routes()
|
public function routes()
|
||||||
|
|||||||
+1
-1
Submodule public/assets/admin updated: 2d650830ae...30dcb220eb
Reference in New Issue
Block a user