2026-03-11 23:33:43 +00:00
|
|
|
#!/usr/bin/env bash
|
2026-03-20 12:51:45 +00:00
|
|
|
# Install auth-rt binary.
|
2026-03-11 23:33:43 +00:00
|
|
|
#
|
2026-03-20 12:51:45 +00:00
|
|
|
# Mode 1 (local build): ./install.sh [bin-dir]
|
|
|
|
|
# Requires Go. Compiles from source and installs.
|
|
|
|
|
#
|
|
|
|
|
# Mode 2 (download): ./install.sh --download [bin-dir]
|
|
|
|
|
# Downloads pre-built binary from Forgejo release.
|
|
|
|
|
#
|
|
|
|
|
# Default bin dir: ~/.local/bin
|
2026-03-11 23:33:43 +00:00
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
2026-03-20 12:51:45 +00:00
|
|
|
FORGEJO="http://192.168.0.108:3030"
|
|
|
|
|
REPO="agent-skills/auth-runtime"
|
|
|
|
|
BIN_DIR="$HOME/.local/bin"
|
|
|
|
|
MODE="local"
|
|
|
|
|
|
|
|
|
|
for arg in "$@"; do
|
|
|
|
|
case "$arg" in
|
|
|
|
|
--download) MODE="download" ;;
|
|
|
|
|
-*) echo "Unknown flag: $arg"; exit 1 ;;
|
|
|
|
|
*) BIN_DIR="$arg" ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2026-03-20 10:26:20 +00:00
|
|
|
mkdir -p "$BIN_DIR"
|
2026-03-11 23:33:43 +00:00
|
|
|
|
2026-03-20 12:51:45 +00:00
|
|
|
if [ "$MODE" = "download" ]; then
|
|
|
|
|
# Detect platform
|
|
|
|
|
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
|
|
|
|
ARCH="$(uname -m)"
|
|
|
|
|
case "$ARCH" in
|
|
|
|
|
x86_64) ARCH="amd64" ;;
|
|
|
|
|
aarch64) ARCH="arm64" ;;
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
ASSET="auth-rt-${OS}-${ARCH}"
|
|
|
|
|
URL="$FORGEJO/$REPO/releases/download/latest/$ASSET"
|
|
|
|
|
|
|
|
|
|
echo "Downloading $ASSET..."
|
|
|
|
|
if command -v curl &>/dev/null; then
|
|
|
|
|
curl -fsSL "$URL" -o "$BIN_DIR/auth-rt"
|
|
|
|
|
elif command -v wget &>/dev/null; then
|
|
|
|
|
wget -q "$URL" -O "$BIN_DIR/auth-rt"
|
|
|
|
|
else
|
|
|
|
|
echo "ERROR: curl or wget required"; exit 1
|
|
|
|
|
fi
|
|
|
|
|
chmod +x "$BIN_DIR/auth-rt"
|
|
|
|
|
echo "Installed: $BIN_DIR/auth-rt (downloaded)"
|
|
|
|
|
else
|
|
|
|
|
# Local build
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
|
CLI_DIR="$SCRIPT_DIR/cli"
|
|
|
|
|
|
|
|
|
|
if ! command -v go &>/dev/null; then
|
|
|
|
|
echo "Go not found. Use --download to fetch pre-built binary instead."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2026-03-11 23:33:43 +00:00
|
|
|
|
2026-03-20 12:51:45 +00:00
|
|
|
echo "Building auth-rt..."
|
|
|
|
|
cd "$CLI_DIR"
|
|
|
|
|
go build -ldflags="-s -w" -o "$BIN_DIR/auth-rt" .
|
|
|
|
|
echo "Installed: $BIN_DIR/auth-rt (built from source)"
|
|
|
|
|
fi
|