-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·83 lines (72 loc) · 2.51 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·83 lines (72 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/sh
# Install the agentcap binary from GitHub Releases.
#
# curl -fsSL https://raw.githubusercontent.com/huggingface/agentcap/main/scripts/install.sh | sh
#
# Detects the platform, downloads the matching prebuilt binary, and installs it
# onto your PATH. Flags (pass after `sh -s --` when piping):
# -b <dir> install dir (default: $HOME/.local/bin; env: AGENTCAP_INSTALL_DIR)
# -v <tag> release tag to fetch (default: latest; env: AGENTCAP_VERSION)
set -eu
REPO="huggingface/agentcap"
BINDIR="${AGENTCAP_INSTALL_DIR:-$HOME/.local/bin}"
VERSION="${AGENTCAP_VERSION:-latest}"
usage() {
echo "usage: install.sh [-b install-dir] [-v release-tag]" >&2
exit "${1:-2}"
}
while getopts "b:v:h" opt; do
case "$opt" in
b) BINDIR="$OPTARG" ;;
v) VERSION="$OPTARG" ;;
h) usage 0 ;;
*) usage 2 ;;
esac
done
# (OS, arch) -> the asset name the release workflow publishes. Only these two
# targets are built; everything else falls through to build-from-source.
case "$(uname -s)-$(uname -m)" in
Linux-x86_64) asset="agentcap-x86_64-linux" ;;
Darwin-arm64 | Darwin-aarch64) asset="agentcap-arm64-apple-darwin" ;;
*)
echo "agentcap: no prebuilt binary for $(uname -s)/$(uname -m)." >&2
echo "Build from source: https://github.com/$REPO#building-from-source" >&2
exit 1
;;
esac
if [ "$VERSION" = latest ]; then
url="https://github.com/$REPO/releases/latest/download/$asset"
else
url="https://github.com/$REPO/releases/download/$VERSION/$asset"
fi
# Download to a temp file so a failed/partial fetch never lands on PATH.
tmp="$(mktemp 2>/dev/null || mktemp -t agentcap)"
trap 'rm -f "$tmp"' EXIT INT TERM
if command -v curl >/dev/null 2>&1; then
fetch() { curl -fsSL "$1" -o "$2"; }
elif command -v wget >/dev/null 2>&1; then
fetch() { wget -qO "$2" "$1"; }
else
echo "agentcap: need curl or wget on PATH to download." >&2
exit 1
fi
echo "Downloading $asset ($VERSION)…"
if ! fetch "$url" "$tmp"; then
echo "agentcap: download failed: $url" >&2
echo " (no matching release published yet? see https://github.com/$REPO/releases)" >&2
exit 1
fi
mkdir -p "$BINDIR"
chmod +x "$tmp"
mv "$tmp" "$BINDIR/agentcap"
trap - EXIT INT TERM
echo "Installed agentcap -> $BINDIR/agentcap"
"$BINDIR/agentcap" --version 2>/dev/null || true
case ":$PATH:" in
*":$BINDIR:"*) ;;
*)
echo
echo "$BINDIR is not on your PATH. Add it:"
echo " export PATH=\"$BINDIR:\$PATH\""
;;
esac