Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@
"value": "text/plain; charset=utf-8"
}
]
},
{
"source": "/install-agent",
"headers": [
{
"key": "Content-Type",
"value": "text/plain; charset=utf-8"
}
]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion landpage/src/routes/docs/remote-shell/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{
label: 'Shell',
controller: 'curl -fsSL https://authmesh.dev/install | sh',
server: 'curl -fsSL https://authmesh.dev/install | sh',
server: 'curl -fsSL https://authmesh.dev/install-agent | sh',
},
];
let activeInstallMethod = $state(0);
Expand Down
4 changes: 1 addition & 3 deletions landpage/static/install
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Usage: curl -fsSL https://authmesh.dev/install | sh
#
# Detects OS and architecture, downloads the latest release from GitHub,
# and installs amesh + amesh-agent into /usr/local/bin (or ~/.local/bin).
# and installs amesh into /usr/local/bin (or ~/.local/bin).
#
# Environment variables:
# AMESH_VERSION — install a specific version (e.g., "0.5.1")
Expand Down Expand Up @@ -115,14 +115,12 @@ main() {
# Install binaries
if needs_sudo "$INSTALL_DIR"; then
sudo install -m 755 "${TMPDIR}/amesh" "${INSTALL_DIR}/amesh"
sudo install -m 755 "${TMPDIR}/amesh-agent" "${INSTALL_DIR}/amesh-agent"
# macOS Secure Enclave helper (only present in darwin tarballs)
if [ -f "${TMPDIR}/amesh-se-helper" ]; then
sudo install -m 755 "${TMPDIR}/amesh-se-helper" "${INSTALL_DIR}/amesh-se-helper"
fi
else
install -m 755 "${TMPDIR}/amesh" "${INSTALL_DIR}/amesh"
install -m 755 "${TMPDIR}/amesh-agent" "${INSTALL_DIR}/amesh-agent"
if [ -f "${TMPDIR}/amesh-se-helper" ]; then
install -m 755 "${TMPDIR}/amesh-se-helper" "${INSTALL_DIR}/amesh-se-helper"
fi
Expand Down
146 changes: 146 additions & 0 deletions landpage/static/install-agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#!/bin/sh
# Install script for amesh-agent — the target daemon for remote shell.
# Usage: curl -fsSL https://authmesh.dev/install-agent | sh
#
# Detects OS and architecture, downloads the latest release from GitHub,
# and installs amesh-agent into /usr/local/bin (or ~/.local/bin).
#
# Environment variables:
# AMESH_VERSION — install a specific version (e.g., "0.5.2")
# AMESH_INSTALL — custom install directory (default: /usr/local/bin or ~/.local/bin)

set -e

REPO="ameshdev/amesh"
BASE_URL="https://github.com/${REPO}/releases"

# --- Helpers ---

log() {
printf '%s\n' "$1"
}

err() {
printf 'Error: %s\n' "$1" >&2
exit 1
}

need() {
command -v "$1" >/dev/null 2>&1 || err "required command not found: $1"
}

# --- Detect platform ---

detect_os() {
case "$(uname -s)" in
Linux*) echo "linux" ;;
Darwin*) echo "darwin" ;;
*) err "unsupported OS: $(uname -s)" ;;
esac
}

detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "x64" ;;
aarch64|arm64) echo "arm64" ;;
*) err "unsupported architecture: $(uname -m)" ;;
esac
}

# --- Resolve version ---

resolve_version() {
if [ -n "${AMESH_VERSION}" ]; then
echo "${AMESH_VERSION}"
return
fi

# Fetch latest release tag from GitHub API
need curl
tag=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" \
| grep '"tag_name"' | head -1 | sed 's/.*"v\(.*\)".*/\1/')
[ -n "$tag" ] || err "could not determine latest version"
echo "$tag"
}

# --- Choose install directory ---

choose_install_dir() {
if [ -n "${AMESH_INSTALL}" ]; then
echo "${AMESH_INSTALL}"
return
fi

if [ -w /usr/local/bin ]; then
echo "/usr/local/bin"
elif command -v sudo >/dev/null 2>&1; then
echo "/usr/local/bin"
else
mkdir -p "${HOME}/.local/bin"
echo "${HOME}/.local/bin"
fi
}

needs_sudo() {
[ ! -w "$1" ] && command -v sudo >/dev/null 2>&1
}

# --- Main ---

main() {
need curl
need tar

OS=$(detect_os)
ARCH=$(detect_arch)
VERSION=$(resolve_version)
INSTALL_DIR=$(choose_install_dir)

TARBALL="amesh-${VERSION}-${OS}-${ARCH}.tar.gz"
URL="${BASE_URL}/download/v${VERSION}/${TARBALL}"

log "Installing amesh-agent v${VERSION} (${OS}/${ARCH})"
log " from: ${URL}"
log " to: ${INSTALL_DIR}"

# Download and extract to a temp directory
TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT

curl -fsSL "$URL" -o "${TMPDIR}/${TARBALL}" \
|| err "download failed — check that v${VERSION} exists for ${OS}-${ARCH}"

tar -xzf "${TMPDIR}/${TARBALL}" -C "$TMPDIR"

# Install binary
if needs_sudo "$INSTALL_DIR"; then
sudo install -m 755 "${TMPDIR}/amesh-agent" "${INSTALL_DIR}/amesh-agent"
else
install -m 755 "${TMPDIR}/amesh-agent" "${INSTALL_DIR}/amesh-agent"
fi

# Verify
if "${INSTALL_DIR}/amesh-agent" --version >/dev/null 2>&1; then
INSTALLED_VERSION=$("${INSTALL_DIR}/amesh-agent" --version 2>&1)
log ""
log "amesh-agent installed: ${INSTALLED_VERSION}"
else
log ""
log "amesh-agent installed to ${INSTALL_DIR}/amesh-agent"
fi

# Warn if install dir is not in PATH
case ":${PATH}:" in
*":${INSTALL_DIR}:"*) ;;
*)
log ""
log "Note: ${INSTALL_DIR} is not in your PATH."
log " Add it with: export PATH=\"${INSTALL_DIR}:\$PATH\""
;;
esac

log ""
log "Get started: amesh-agent agent start"
}

main
Loading