interplane.Get Omega
Read in your language

aegis-runtime-mv

Native Rust agent runtime: Axum WebSocket/SSE/REST gateway, heartbeat scheduler, dependency-aware task workflow, SQLite storage. Attachment of AienOS. Pre-alpha.

Brought by drakestapleton

branch main Branches Tags History

aegis-runtime-mv / install.sh

156 lines · 4234 bytes Raw Blame History
1#!/bin/sh
2set -eu
3
4# AEGIS native binary installer
5# Pure compiled Rust runtime for sovereign AI agents.
6
7REPO="aien-dev/aegis-runtime"
8BIN_NAME="aegis"
9INSTALL_DIR="${AEGIS_INSTALL_DIR:-$HOME/.local/bin}"
10STAGED_DIR="${AEGIS_STAGED_DIR:-}"
11
12# Parse optional command-line arguments
13while [ $# -gt 0 ]; do
14 case "$1" in
15 --staged)
16 STAGED_DIR="$2"
17 shift 2
18 ;;
19 --install-dir)
20 INSTALL_DIR="$2"
21 shift 2
22 ;;
23 --help|-h)
24 echo "Usage: install.sh [--staged <dir>] [--install-dir <dir>]"
25 exit 0
26 ;;
27 *)
28 echo "Unknown option: $1" >&2
29 exit 1
30 ;;
31 esac
32done
33
34OS="$(uname -s)"
35if [ "$OS" != "Linux" ]; then
36 echo "Error: Operating system $OS is not supported. Linux is required." >&2
37 exit 1
38fi
39
40RAW_ARCH="$(uname -m)"
41case "$RAW_ARCH" in
42 aarch64|arm64)
43 ARCH="aarch64"
44 ;;
45 x86_64|amd64)
46 ARCH="x86_64"
47 ;;
48 *)
49 echo "Error: Architecture $RAW_ARCH is not supported." >&2
50 exit 1
51 ;;
52esac
53
54echo "[+] Platform: Linux ($ARCH)"
55
56TARBALL="aegis-linux-${ARCH}.tar.gz"
57CHECKSUM_FILE="${TARBALL}.sha256"
58
59TMP_DIR="$(mktemp -d)"
60cleanup() {
61 rm -rf "$TMP_DIR"
62}
63trap cleanup EXIT INT TERM
64
65if [ -n "$STAGED_DIR" ]; then
66 echo "[+] Installing from local staged directory: $STAGED_DIR"
67 if [ -f "$STAGED_DIR/$TARBALL" ]; then
68 cp "$STAGED_DIR/$TARBALL" "$TMP_DIR/$TARBALL"
69 if [ -f "$STAGED_DIR/$CHECKSUM_FILE" ]; then
70 cp "$STAGED_DIR/$CHECKSUM_FILE" "$TMP_DIR/$CHECKSUM_FILE"
71 fi
72 else
73 MATCHING="$(find "$STAGED_DIR" -maxdepth 1 -name "aegis-*-linux-${ARCH}.tar.gz" 2>/dev/null | head -n 1)"
74 if [ -n "$MATCHING" ] && [ -f "$MATCHING" ]; then
75 cp "$MATCHING" "$TMP_DIR/$TARBALL"
76 if [ -f "${MATCHING}.sha256" ]; then
77 cp "${MATCHING}.sha256" "$TMP_DIR/$CHECKSUM_FILE"
78 fi
79 else
80 echo "Error: Could not locate $TARBALL in staged directory $STAGED_DIR" >&2
81 exit 1
82 fi
83 fi
84else
85 BASE_URL="https://github.com/${REPO}/releases/latest/download"
86 DOWNLOAD_URL="${BASE_URL}/${TARBALL}"
87 CHECKSUM_URL="${BASE_URL}/${CHECKSUM_FILE}"
88
89 echo "[+] Downloading $DOWNLOAD_URL..."
90 if command -v curl >/dev/null 2>&1; then
91 curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DIR/$TARBALL"
92 curl -fsSL "$CHECKSUM_URL" -o "$TMP_DIR/$CHECKSUM_FILE"
93 elif command -v wget >/dev/null 2>&1; then
94 wget -qO "$TMP_DIR/$TARBALL" "$DOWNLOAD_URL"
95 wget -qO "$TMP_DIR/$CHECKSUM_FILE" "$CHECKSUM_URL"
96 else
97 echo "Error: Neither curl nor wget was found on PATH." >&2
98 exit 1
99 fi
100fi
101
102# Every install path verifies the tarball. A missing or empty checksum, a
103# missing hash tool or a mismatch stops the install.
104if [ ! -s "$TMP_DIR/$CHECKSUM_FILE" ]; then
105 echo "Error: No checksum file for $TARBALL; refusing to install an unverified binary." >&2
106 exit 1
107fi
108
109echo "[+] Verifying SHA256 checksum..."
110EXPECTED_HASH="$(awk 'NR == 1 {print $1}' "$TMP_DIR/$CHECKSUM_FILE")"
111if command -v sha256sum >/dev/null 2>&1; then
112 ACTUAL_HASH="$(sha256sum "$TMP_DIR/$TARBALL" | awk '{print $1}')"
113elif command -v shasum >/dev/null 2>&1; then
114 ACTUAL_HASH="$(shasum -a 256 "$TMP_DIR/$TARBALL" | awk '{print $1}')"
115else
116 echo "Error: Neither sha256sum nor shasum found; cannot verify $TARBALL." >&2
117 exit 1
118fi
119
120if [ -z "$EXPECTED_HASH" ] || [ "$EXPECTED_HASH" != "$ACTUAL_HASH" ]; then
121 echo "Error: Checksum verification failed!" >&2
122 echo "Expected: $EXPECTED_HASH" >&2
123 echo "Actual: $ACTUAL_HASH" >&2
124 exit 1
125fi
126echo "[+] Checksum verified: $ACTUAL_HASH"
127
128echo "[+] Extracting $TARBALL..."
129tar -xzf "$TMP_DIR/$TARBALL" -C "$TMP_DIR"
130
131if [ ! -f "$TMP_DIR/$BIN_NAME" ]; then
132 echo "Error: Binary $BIN_NAME not found in tarball archive." >&2
133 exit 1
134fi
135
136mkdir -p "$INSTALL_DIR"
137cp "$TMP_DIR/$BIN_NAME" "$INSTALL_DIR/$BIN_NAME"
138chmod +x "$INSTALL_DIR/$BIN_NAME"
139
140echo "[+] Installed $BIN_NAME to $INSTALL_DIR/$BIN_NAME"
141
142case ":$PATH:" in
143 *":$INSTALL_DIR:"*)
144 ;;
145 *)
146 echo ""
147 echo "Note: $INSTALL_DIR is not in your PATH."
148 echo "To enable direct execution, add the following to your ~/.bashrc or ~/.profile:"
149 echo " export PATH=\"$INSTALL_DIR:\$PATH\""
150 echo ""
151 ;;
152esac
153
154echo "[+] Verification:"
155"$INSTALL_DIR/$BIN_NAME" --help | head -n 2
156echo "[+] Installation complete."