#!/usr/bin/env bash # Canvryn Host Agent — Official One-Line Installer (Linux systemd) # Usage: curl -fsSL https://get.canvryn.com | sudo bash -s -- --enroll set -euo pipefail VERSION="0.7.1" ENROLL_TOKEN="" while [[ $# -gt 0 ]]; do case "$1" in --enroll) ENROLL_TOKEN="${2:-}"; shift 2 ;; *) shift ;; esac done echo "=== Canvryn Host Agent v${VERSION} Installer ===" if [[ "$EUID" -ne 0 ]]; then echo "Please run with sudo: curl -fsSL https://get.canvryn.com | sudo bash" >&2 exit 1 fi if ! command -v python3 >/dev/null 2>&1; then echo "Python 3.10+ is required." >&2; exit 1 fi if ! command -v systemctl >/dev/null 2>&1; then echo "systemd is required on Linux." >&2; exit 1 fi id -u canvryn-host-agent >/dev/null 2>&1 || useradd --system --no-create-home --shell /usr/sbin/nologin canvryn-host-agent mkdir -p /opt/canvryn-host-agent/releases/${VERSION} /etc/canvryn-host-agent/keys /var/lib/canvryn-host-agent /var/lib/canvryn-host-operator chmod 700 /etc/canvryn-host-agent/keys /var/lib/canvryn-host-operator chown canvryn-host-agent:canvryn-host-agent /var/lib/canvryn-host-agent chmod 700 /var/lib/canvryn-host-agent echo "[ok] Host directories & unprivileged user prepared." if [[ -n "$ENROLL_TOKEN" ]]; then echo "[next] Enrollment token received (${#ENROLL_TOKEN} chars). Complete enrollment at https://mcp.sanyangpetroleum.com." else echo "[info] Run with --enroll from your Canvryn Gateway dashboard to link this host." fi