feat: install a new Docker server from the install screen (Linux)

The install commands ask coa_core::platform::flavor() once and hand a Docker
install to src-tauri/src/docker_install.rs; the repack arm of each command is
untouched (an early return and an extra optional parameter are all that changed
in lib.rs). New command install_environment tells the screen the kind of server,
the suggested folder (~/CoaServer) and why Docker cannot be used, if it cannot.

On Linux the install screen shows the game data folder (used in place, read-only)
and the server package (a folder or an address; there is no default address until
a signed Linux package is published), and disables Install until both are given
and Docker works. It shows Docker's own message with a "Check again" button when
Docker is missing, stopped or not allowed for the user. The Windows screen is
unchanged (checked side by side in the browser mock).

A debug build (tauri dev) accepts another package key named in
COA_DEV_TRUSTED_KEY, to try the installer on a package signed with a throwaway
key; a release build always uses the embedded key.

New text is English only for now (other languages fall back to it).
This commit is contained in:
Fabien F. committed 2026-10-08 17:28:52 +02:00
1 parent 58c1e1aee0
commit 45a699d2ca
9 files changed
+276 -16

No files matched your search

+1
View File
@@ -91,6 +91,7 @@ export {};
if(cmd==="report_targets") return [{id:"manager",repo:"Corfirean/coa-server-manager",ours:true},{id:"companions",repo:"Corfirean/mod-coa-playerbots",ours:true},{id:"squid",repo:"Zyth45/mod-playerbots",ours:false}];
if(cmd==="open_link"){(window as any).__lastLink=args.url;return null;}
if(cmd==="export_diagnostics") return "C:\\Users\\you\\Desktop\\CoA-Diagnostics-20261001-140000.zip";
if(cmd==="install_environment"){const docker=new URLSearchParams(location.search).get("flavor")==="docker";return docker?{flavor:"docker",default_dir:"/home/you/CoaServer",docker_problem:new URLSearchParams(location.search).has("nodocker")?"permission denied while trying to connect to the Docker daemon socket":null}:{flavor:"repack",default_dir:"C:\\Games\\CoA Server",docker_problem:null};}
if(cmd==="install_preflight") return {ok:true,problems:[],free_bytes:210*2**30};
if(cmd==="install_requirements") return {download_bytes:Math.round(5.9*2**30),unpacked_bytes:Math.round(11.4*2**30),version:"0.2.0"};
if(cmd==="list_accounts"){const w=window as any;w.__acc=w.__acc??[{id:2,name:"ALICE",access:3,online:true,last_login:"2026-10-01 12:04:11",characters:4},{id:5,name:"BOB",access:0,online:false,last_login:null,characters:0},{id:6,name:"CAROL",access:2,online:false,last_login:"2026-09-30 21:40:02",characters:2}];return w.__acc;}
+8
View File
@@ -190,6 +190,14 @@ const en = {
"install.localPkg": "Install from a local package folder instead of downloading",
"install.localPkgHint": "(leave empty to download)",
"install.button": "Install",
"install.docker.title": "Docker is needed",
"install.docker.text": "On Linux the server runs in Docker. Install Docker and start it, or allow your user to use it, then check again.",
"install.docker.retry": "Check again",
"install.data.label": "Game data folder",
"install.data.hint": "The folder with the game's dbc, maps, vmaps and mmaps. It is used where it is and never changed.",
"install.data.dialogTitle": "Choose the game data folder",
"install.linuxPkg.label": "Server package",
"install.linuxPkg.hint": "A folder or an address of the Linux server package",
"install.progressTitle": "Preparing your server",
"install.progressText": "This can take a few minutes. You can leave this window open.",
"install.step.checking": "Checking your computer",
+13 -2
View File
@@ -265,6 +265,16 @@ export interface ReportTarget {
ours: boolean;
}
/** The kind of server this computer installs: a repack (Windows) or Docker containers (Linux). */
export type Flavor = "repack" | "docker";
export interface InstallEnvironment {
flavor: Flavor;
default_dir: string;
/** Why Docker cannot be used, in its own words; null when it works. */
docker_problem: string | null;
}
export interface InstallRequirements {
download_bytes: number;
unpacked_bytes: number;
@@ -454,7 +464,8 @@ export const api = {
deleteBackup: (id: string, backupId: string) => invoke<void>("delete_backup", { id, backupId }),
restoreConfigs: (id: string, backupId: string) => invoke<RecoveryPoint>("restore_backup_configs", { id, backupId }),
restoreDatabase: (id: string, backupId: string, database: string) => invoke<DbRestore>("restore_backup_database", { id, backupId, database }),
installPreflight: (dest: string, needed?: number) => invoke<Preflight>("install_preflight", { dest, needed: needed ?? null }),
installEnvironment: () => invoke<InstallEnvironment>("install_environment"),
installPreflight: (dest: string, needed?: number, gameData?: string) => invoke<Preflight>("install_preflight", { dest, needed: needed ?? null, gameData: gameData ?? null }),
installRequirements: (pkg?: string) => invoke<InstallRequirements>("install_requirements", { package: pkg ?? null }),
realmlistProfiles: (id: string) => invoke<{ profiles: RealmProfile[]; active: string | null }>("realmlist_profiles", { id }),
realmlistSave: (id: string, profileId: string | null, name: string, data: string) => invoke<RealmProfile>("realmlist_save", { id, profileId, name, data }),
@@ -473,7 +484,7 @@ export const api = {
accountSetAccess: (id: string, name: string, level: number) => invoke<void>("account_set_access", { id, name, level }),
accountRename: (id: string, name: string, newName: string, password: string) => invoke<void>("account_rename", { id, name, newName, password }),
accountDelete: (id: string, name: string) => invoke<void>("account_delete", { id, name }),
installNew: (dest: string, pkg?: string) => invoke<ServerSummary>("install_new", { dest, package: pkg ?? null }),
installNew: (dest: string, pkg?: string, gameData?: string) => invoke<ServerSummary>("install_new", { dest, package: pkg ?? null, gameData: gameData ?? null }),
cancelInstall: () => invoke<void>("cancel_install"),
createAccount: (id: string, username: string, password: string, administrator: boolean) =>
invoke<void>("create_account", { id, username, password, administrator }),
+53 -10
View File
@@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
import { listen } from "@tauri-apps/api/event";
import { open } from "@tauri-apps/plugin-dialog";
import { Check, ChevronDown, ChevronRight, Loader2 } from "lucide-react";
import { api, asUiError, type InstallRequirements, type InstallStep, type Preflight, type ServerSummary, type UiError } from "@/lib/api";
import { api, asUiError, type InstallEnvironment, type InstallRequirements, type InstallStep, type Preflight, type ServerSummary, type UiError } from "@/lib/api";
import { formatBytes } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";
@@ -33,6 +33,19 @@ export function InstallServer(props: { canCancel: boolean; onCancel: () => void;
const [pkg, setPkg] = useState("");
const [installed, setInstalled] = useState<ServerSummary | null>(null);
const [showDetails, setShowDetails] = useState(false);
// What this computer installs. A repack (Windows) needs nothing more than a folder; Docker (Linux) also needs the game data
// folder and a package, and Docker itself.
const [env, setEnv] = useState<InstallEnvironment | null>(null);
const [gameData, setGameData] = useState("");
const docker = env?.flavor === "docker";
function loadEnvironment(first: boolean) {
void api.installEnvironment().then((e) => {
setEnv(e);
if (first && e.flavor === "docker") setDest(e.default_dir);
}).catch(() => setEnv(null));
}
useEffect(() => loadEnvironment(true), []);
// how big the server is, from the package's signed list (re-read when another package source is entered)
useEffect(() => {
@@ -43,9 +56,9 @@ export function InstallServer(props: { canCancel: boolean; onCancel: () => void;
// room for the unpacked server plus the download that is removed afterwards
const needed = req ? req.unpacked_bytes + req.download_bytes : undefined;
useEffect(() => {
const timer = setTimeout(() => void api.installPreflight(dest, needed).then(setPre).catch(() => setPre(null)), 250);
const timer = setTimeout(() => void api.installPreflight(dest, needed, docker ? gameData.trim() : undefined).then(setPre).catch(() => setPre(null)), 250);
return () => clearTimeout(timer);
}, [dest, needed]);
}, [dest, needed, docker, gameData]);
useEffect(() => {
const un = listen<InstallStep>("install-progress", (e) => setStep(e.payload));
@@ -56,7 +69,12 @@ export function InstallServer(props: { canCancel: boolean; onCancel: () => void;
async function browse() {
const picked = await open({ directory: true, multiple: false, title: t("install.dialogTitle") });
if (typeof picked === "string") setDest(picked.replace(/[\\/]+$/, "") + (picked.toLowerCase().includes("coa") ? "" : "\\CoA Server"));
if (typeof picked === "string") setDest(picked.replace(/[\\/]+$/, "") + (picked.toLowerCase().includes("coa") ? "" : docker ? "/CoaServer" : "\\CoA Server"));
}
async function browseGameData() {
const picked = await open({ directory: true, multiple: false, title: t("install.data.dialogTitle") });
if (typeof picked === "string") setGameData(picked);
}
async function browsePackage() {
@@ -69,7 +87,7 @@ export function InstallServer(props: { canCancel: boolean; onCancel: () => void;
setPhase("installing");
setStep({ step: "Preparing your server", percent: 0, detail: null });
try {
const s = await api.installNew(dest, pkg.trim() || undefined);
const s = await api.installNew(dest, pkg.trim() || undefined, docker ? gameData.trim() : undefined);
setInstalled(s);
setPhase("done");
} catch (e) {
@@ -139,9 +157,34 @@ export function InstallServer(props: { canCancel: boolean; onCancel: () => void;
</div>
</div>
{pre && pre.problems.length > 0 && (
{docker && (
<div>
<label htmlFor="gamedata" className="text-sm text-muted">{t("install.data.label")}</label>
<div className="mt-1 flex gap-2">
<input id="gamedata" value={gameData} onChange={(e) => setGameData(e.target.value)} className="selectable flex-1 rounded-md border border-line bg-card px-3 py-2.5 text-[15px] outline-none focus:border-gold" />
<Button onClick={browseGameData}>{t("install.browse")}</Button>
</div>
<p className="mt-1 text-xs text-muted">{t("install.data.hint")}</p>
<label htmlFor="linuxpkg" className="mt-4 block text-sm text-muted">{t("install.linuxPkg.label")}</label>
<div className="mt-1 flex gap-2">
<input id="linuxpkg" value={pkg} onChange={(e) => setPkg(e.target.value)} placeholder={t("install.linuxPkg.hint")} className="selectable flex-1 rounded-md border border-line bg-card px-3 py-2.5 text-[15px] outline-none focus:border-gold" />
<Button onClick={browsePackage}>{t("install.browse")}</Button>
</div>
</div>
)}
{docker && env?.docker_problem && (
<Card className="border-warn/40 p-4" role="alert">
{pre.problems.map((p) => (
<p className="font-medium text-warn">{t("install.docker.title")}</p>
<p className="mt-1 text-sm text-muted">{t("install.docker.text")}</p>
<pre className="mt-2 max-h-24 overflow-auto whitespace-pre-wrap rounded bg-black/40 p-2 text-xs">{env.docker_problem}</pre>
<Button className="mt-3" size="sm" onClick={() => loadEnvironment(false)}>{t("install.docker.retry")}</Button>
</Card>
)}
{pre && pre.problems.some((p) => !(docker && !gameData.trim() && p.code.startsWith("data"))) && (
<Card className="border-warn/40 p-4" role="alert">
{pre.problems.filter((p) => !(docker && !gameData.trim() && p.code.startsWith("data"))).map((p) => (
<p key={p.code} className="text-sm text-warn">{p.message}</p>
))}
</Card>
@@ -170,7 +213,7 @@ export function InstallServer(props: { canCancel: boolean; onCancel: () => void;
</Card>
)}
<div>
{!docker && <div>
<button onClick={() => setShowAdvanced((v) => !v)} aria-expanded={showAdvanced} className="flex cursor-pointer items-center gap-1 text-sm text-muted hover:text-ink">
{showAdvanced ? <ChevronDown className="h-4 w-4" aria-hidden /> : <ChevronRight className="h-4 w-4" aria-hidden />}
{t("install.advanced")}
@@ -184,10 +227,10 @@ export function InstallServer(props: { canCancel: boolean; onCancel: () => void;
</div>
</div>
)}
</div>
</div>}
<div className="flex items-center gap-3">
<Button variant="primary" size="md" disabled={!pre?.ok} onClick={() => void install()}>
<Button variant="primary" size="md" disabled={!pre?.ok || (docker && (!!env?.docker_problem || !gameData.trim() || !pkg.trim()))} onClick={() => void install()}>
{t("install.button")}
</Button>
{props.canCancel && (