diff --git a/server/internal/api/handlers.go b/server/internal/api/handlers.go index 0f53076..3600e01 100644 --- a/server/internal/api/handlers.go +++ b/server/internal/api/handlers.go @@ -124,10 +124,16 @@ func newServer(c *gin.Context) { host, s.ServerID, token, ) + installCmdPS := fmt.Sprintf( + `irm "%s/install.ps1?server_id=%s&token=%s" | iex`, + host, s.ServerID, token, + ) + c.JSON(http.StatusOK, gin.H{ - "server_id": s.ServerID, - "pre_reg_token": token, - "install_command": installCmd, + "server_id": s.ServerID, + "pre_reg_token": token, + "install_command": installCmd, + "install_command_ps": installCmdPS, }) } diff --git a/web/app/servers/new/page.tsx b/web/app/servers/new/page.tsx index c0bbf33..a085ad1 100644 --- a/web/app/servers/new/page.tsx +++ b/web/app/servers/new/page.tsx @@ -8,15 +8,18 @@ import { Button, Card, CardHeader, CardTitle } from "@/components/ui"; export default function NewServerPage() { const [result, setResult] = useState(null); const [copied, setCopied] = useState(false); + const [os, setOs] = useState<"linux" | "windows">("linux"); const { mutate: createServer, isPending, error } = useMutation({ mutationFn: api.createServer, onSuccess: (data) => setResult(data), }); + const command = os === "windows" ? result?.install_command_ps : result?.install_command; + const handleCopy = async () => { - if (!result?.install_command) return; - await navigator.clipboard.writeText(result.install_command); + if (!command) return; + await navigator.clipboard.writeText(command); setCopied(true); setTimeout(() => setCopied(false), 2000); }; @@ -65,14 +68,34 @@ export default function NewServerPage() { Valid for 1 hour +
+ {(["linux", "windows"] as const).map((o) => ( + + ))} +
+

- Run this command on the target server as root: + {os === "windows" ? ( + <>Run this in an elevated PowerShell (Run as Administrator): + ) : ( + <>Run this command on the target server as root: + )}

-                  ${" "}
-                  {result.install_command}
+                  {os === "windows" ? "PS>" : "$"}{" "}
+                  {command}