split install and run commands

This commit is contained in:
miloschwartz
2025-12-05 10:51:38 -05:00
parent c5befee134
commit 1cae815be5
3 changed files with 125 additions and 35 deletions

View File

@@ -2237,5 +2237,7 @@
"deviceLoginUseDifferentAccount": "Not you? Use a different account.", "deviceLoginUseDifferentAccount": "Not you? Use a different account.",
"deviceLoginDeviceRequestingAccessToAccount": "A device is requesting access to this account.", "deviceLoginDeviceRequestingAccessToAccount": "A device is requesting access to this account.",
"noData": "No Data", "noData": "No Data",
"machineClients": "Machine Clients" "machineClients": "Machine Clients",
"install": "Install",
"run": "Run"
} }

View File

@@ -68,9 +68,11 @@ interface TunnelTypeOption {
disabled?: boolean; disabled?: boolean;
} }
type CommandItem = string | { title: string; command: string };
type Commands = { type Commands = {
unix: Record<string, string[]>; unix: Record<string, CommandItem[]>;
windows: Record<string, string[]>; windows: Record<string, CommandItem[]>;
}; };
const platforms = ["unix", "windows"] as const; const platforms = ["unix", "windows"] as const;
@@ -132,14 +134,26 @@ export default function Page() {
const commands = { const commands = {
unix: { unix: {
All: [ All: [
`curl -fsSL https://pangolin.net/get-olm.sh | bash`, {
`sudo olm --id ${id} --secret ${secret} --endpoint ${endpoint}` title: t("install"),
command: `curl -fsSL https://pangolin.net/get-olm.sh | bash`
},
{
title: t("run"),
command: `sudo olm --id ${id} --secret ${secret} --endpoint ${endpoint}`
}
] ]
}, },
windows: { windows: {
x64: [ x64: [
`curl -o olm.exe -L "https://github.com/fosrl/olm/releases/download/${version}/olm_windows_installer.exe"`, {
`olm.exe --id ${id} --secret ${secret} --endpoint ${endpoint}` title: t("install"),
command: `curl -o olm.exe -L "https://github.com/fosrl/olm/releases/download/${version}/olm_windows_installer.exe"`
},
{
title: t("run"),
command: `olm.exe --id ${id} --secret ${secret} --endpoint ${endpoint}`
}
] ]
} }
}; };
@@ -170,8 +184,8 @@ export default function Page() {
} }
}; };
const getCommand = () => { const getCommand = (): CommandItem[] => {
const placeholder = [t("unknownCommand")]; const placeholder: CommandItem[] = [t("unknownCommand")];
if (!commands) { if (!commands) {
return placeholder; return placeholder;
} }
@@ -645,13 +659,43 @@ export default function Page() {
<p className="font-bold mb-3"> <p className="font-bold mb-3">
{t("commands")} {t("commands")}
</p> </p>
<div className="mt-2"> <div className="mt-2 space-y-3">
<CopyTextBox {getCommand().map(
text={getCommand().join( (item, index) => {
"\n" const commandText =
)} typeof item ===
outline={true} "string"
/> ? item
: item.command;
const title =
typeof item ===
"string"
? undefined
: item.title;
return (
<div
key={index}
>
{title && (
<p className="text-sm font-medium mb-1.5">
{
title
}
</p>
)}
<CopyTextBox
text={
commandText
}
outline={
true
}
/>
</div>
);
}
)}
</div> </div>
</div> </div>
</div> </div>

View File

@@ -78,13 +78,15 @@ interface RemoteExitNodeOption {
disabled?: boolean; disabled?: boolean;
} }
type CommandItem = string | { title: string; command: string };
type Commands = { type Commands = {
unix: Record<string, string[]>; unix: Record<string, CommandItem[]>;
windows: Record<string, string[]>; windows: Record<string, CommandItem[]>;
docker: Record<string, string[]>; docker: Record<string, CommandItem[]>;
kubernetes: Record<string, string[]>; kubernetes: Record<string, CommandItem[]>;
podman: Record<string, string[]>; podman: Record<string, CommandItem[]>;
nixos: Record<string, string[]>; nixos: Record<string, CommandItem[]>;
}; };
const platforms = [ const platforms = [
@@ -248,14 +250,26 @@ PersistentKeepalive = 5`;
const commands = { const commands = {
unix: { unix: {
All: [ All: [
`curl -fsSL https://pangolin.net/get-newt.sh | bash`, {
`newt --id ${id} --secret ${secret} --endpoint ${endpoint}${acceptClientsFlag}` title: t("install"),
command: `curl -fsSL https://pangolin.net/get-newt.sh | bash`
},
{
title: t("run"),
command: `newt --id ${id} --secret ${secret} --endpoint ${endpoint}${acceptClientsFlag}`
}
] ]
}, },
windows: { windows: {
x64: [ x64: [
`curl -o newt.exe -L "https://github.com/fosrl/newt/releases/download/${version}/newt_windows_amd64.exe"`, {
`newt.exe --id ${id} --secret ${secret} --endpoint ${endpoint}${acceptClientsFlag}` title: t("install"),
command: `curl -o newt.exe -L "https://github.com/fosrl/newt/releases/download/${version}/newt_windows_amd64.exe"`
},
{
title: t("run"),
command: `newt.exe --id ${id} --secret ${secret} --endpoint ${endpoint}${acceptClientsFlag}`
}
] ]
}, },
docker: { docker: {
@@ -356,8 +370,8 @@ WantedBy=default.target`
} }
}; };
const getCommand = () => { const getCommand = (): CommandItem[] => {
const placeholder = [t("unknownCommand")]; const placeholder: CommandItem[] = [t("unknownCommand")];
if (!commands) { if (!commands) {
return placeholder; return placeholder;
} }
@@ -1002,13 +1016,43 @@ WantedBy=default.target`
<p className="font-bold mb-3"> <p className="font-bold mb-3">
{t("commands")} {t("commands")}
</p> </p>
<div className="mt-2"> <div className="mt-2 space-y-3">
<CopyTextBox {getCommand().map(
text={getCommand().join( (item, index) => {
"\n" const commandText =
)} typeof item ===
outline={true} "string"
/> ? item
: item.command;
const title =
typeof item ===
"string"
? undefined
: item.title;
return (
<div
key={index}
>
{title && (
<p className="text-sm font-medium mb-1.5">
{
title
}
</p>
)}
<CopyTextBox
text={
commandText
}
outline={
true
}
/>
</div>
);
}
)}
</div> </div>
</div> </div>
</div> </div>