Skip to content

Commit

Permalink
Have a install script for both relay and agents.
Browse files Browse the repository at this point in the history
  • Loading branch information
nasa42 committed Feb 2, 2025
1 parent 52576de commit 8ba1884
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 31 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ Written in Rust, Webterm is built from the ground up for security, performance,

## Quickstart

1. Install Webterm agent using Cargo:
1. Install the Webterm agent:
```bash
cargo install webterm-agent
# This command will install a single binary at /usr/bin/webterm-agent, no other files will be touched
curl -sSfL https://webterm.run/install.sh | bash
```

2. Start the Webterm agent:
```bash
# Pass --daemon to run the agent in the background
webterm-agent --device-name <DEVICE_NAME> --secret-key <SECRET_KEY>
```

Expand Down
1 change: 1 addition & 0 deletions frontend/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import vitePluginSvgr from "vite-plugin-svgr";

// https://astro.build/config
export default defineConfig({
trailingSlash: "never",
vite: {
plugins: [webtermVersionPlugin(), vitePluginSvgr()],
build: {
Expand Down
110 changes: 102 additions & 8 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@xterm/xterm": "^5.5.0",
"astro": "^5.1.1",
"bootstrap": "^5.3.3",
"ejs": "^3.1.10",
"flatbuffers": "^25.1.24",
"lodash-es": "^4.17.21",
"nanostores": "^0.11.3",
Expand All @@ -34,6 +35,7 @@
},
"devDependencies": {
"@types/bootstrap": "^5.2.10",
"@types/ejs": "^3.1.5",
"@types/lodash-es": "^4.17.12",
"@types/node": "^22.13.0",
"eslint": "^9.17.0",
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/pages/get.ts

This file was deleted.

25 changes: 17 additions & 8 deletions frontend/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@ import { CONFIG } from "../scripts/client/config";
Install the free and open-source agent, built with Rust for high efficiency and extremely light resource
usage.
</p>
<div class="bg-light p-3 rounded mb-4">
<code>
# Install the agent <br />
cargo install webterm-agent <br />
<br />
# Run the agent <br />
webterm-agent --device-name &lt;DEVICE_NAME&gt; --secret-key &lt;SECRET_KEY&gt;
</code>
<div>
<ol>
<li class="mb-4">
<p>Install the agent</p>
<code class="bg-light px-4 py-4 rounded-4 d-block">
curl -sSfL https://webterm.run/install.sh | bash
</code>
</li>

<li class="mb-4">
<p>Run the agent (add <code>--daemon</code> to run in background)</p>

<code class="bg-light px-4 py-4 rounded d-block">
webterm-agent --device-name &lt;DEVICE_NAME&gt; --secret-key &lt;SECRET_KEY&gt;
</code>
</li>
</ol>
</div>
<div class="mt-3">
<a href="https://github.com/nasa42/webterm#quickstart" class="btn btn-outline-primary me-3"
Expand Down
7 changes: 7 additions & 0 deletions frontend/src/pages/install-relay.sh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { APIRoute } from "astro";
import ejs from "ejs";

export const GET: APIRoute = async (_context): Promise<Response> => {
const script = await ejs.renderFile("./src/templates/install.sh.ejs", { binary_name: "webterm-relay" });
return new Response(script);
};
7 changes: 7 additions & 0 deletions frontend/src/pages/install.sh.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { APIRoute } from "astro";
import ejs from "ejs";

export const GET: APIRoute = async (_context): Promise<Response> => {
const script = await ejs.renderFile("./src/templates/install.sh.ejs", { binary_name: "webterm-agent" });
return new Response(script);
};
11 changes: 5 additions & 6 deletions frontend/get.sh → frontend/src/templates/install.sh.ejs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env bash
#
# Usage:
# curl -sSfL https://webterm.run/get | bash
# curl -sSfL https://webterm.run/install.sh | bash

set -euo pipefail

LATEST_VERSION_URL="https://webterm.run/latest.txt"
REPO_BASE_URL="https://github.com/nasa42/webterm/releases/download"
BINARY_NAME="webterm-agent"
BINARY_NAME="<%= binary_name %>"

# By default, install to /usr/bin unless the user provides INSTALL_DIR
DEFAULT_INSTALL_DIR="/usr/bin"
Expand All @@ -27,7 +27,6 @@ echo "Latest version: ${LATEST_VERSION}"
# Check if ${BINARY_NAME} is already installed and get installed version
INSTALLED_VERSION=""
if [ -x "${INSTALL_DIR}/${BINARY_NAME}" ]; then
# Example output: "webterm-agent 0.2.0"
INSTALLED_VERSION="$("${INSTALL_DIR}/${BINARY_NAME}" --version 2>/dev/null | awk '{print $2}')"
echo "Installed version: ${INSTALLED_VERSION}"
fi
Expand All @@ -42,10 +41,10 @@ fi
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64)
ARCHIVE="webterm-agent-x86_64-unknown-linux-gnu.tar.gz"
ARCHIVE="${BINARY_NAME}-x86_64-unknown-linux-gnu.tar.gz"
;;
aarch64|arm64)
ARCHIVE="webterm-agent-aarch64-unknown-linux-gnu.tar.gz"
ARCHIVE="${BINARY_NAME}-aarch64-unknown-linux-gnu.tar.gz"
;;
*)
echo "Unsupported architecture: ${ARCH}"
Expand All @@ -54,7 +53,7 @@ case "${ARCH}" in
;;
esac

DOWNLOAD_URL="${REPO_BASE_URL}/webterm-agent-v${LATEST_VERSION}/${ARCHIVE}"
DOWNLOAD_URL="${REPO_BASE_URL}/${BINARY_NAME}-v${LATEST_VERSION}/${ARCHIVE}"

echo "Downloading ${BINARY_NAME} ${LATEST_VERSION} for architecture ${ARCH}..."
curl -sSfL "${DOWNLOAD_URL}" -o "${ARCHIVE}"
Expand Down

0 comments on commit 8ba1884

Please sign in to comment.