forked from google/sam
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·68 lines (54 loc) · 1.84 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·68 lines (54 loc) · 1.84 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
#!/usr/bin/env bash
set -e
REPO="google/sam"
INSTALL_DIR="/usr/local/bin"
echo "Installing SAM from $REPO..."
# Get OS and Arch
OS="$(uname -s)"
case "${OS}" in
Linux*) OS_NAME="Linux";;
Darwin*) OS_NAME="Darwin";;
*) echo "Unsupported OS: ${OS}"; exit 1;;
esac
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64*) ARCH_NAME="x86_64";;
aarch64*) ARCH_NAME="arm64";;
arm64*) ARCH_NAME="arm64";;
*) echo "Unsupported architecture: ${ARCH}"; exit 1;;
esac
# Get latest release version
echo "Fetching latest release information..."
LATEST_RELEASE_URL="https://api.github.com/repos/${REPO}/releases/latest"
VERSION=$(curl -s $LATEST_RELEASE_URL | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$VERSION" ]; then
echo "Error: Could not find the latest release."
exit 1
fi
echo "Found latest version: ${VERSION}"
# Construct download URL (matches goreleaser name template)
TAR_NAME="sam_${OS_NAME}_${ARCH_NAME}.tar.gz"
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${TAR_NAME}"
# Create a temporary directory
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
echo "Downloading ${DOWNLOAD_URL}..."
if ! curl -sfL -o "${TAR_NAME}" "${DOWNLOAD_URL}"; then
echo "Error: Failed to download ${DOWNLOAD_URL}"
rm -rf "$TMP_DIR"
exit 1
fi
echo "Extracting..."
tar -xzf "${TAR_NAME}"
echo "Installing to ${INSTALL_DIR} (may require sudo)..."
# In some environments, sudo might not be available or required
if [ -w "$INSTALL_DIR" ]; then
mv sam-node sam-control-plane sam-router mcp-client "$INSTALL_DIR/" 2>/dev/null || true
else
sudo mv sam-node sam-control-plane sam-router mcp-client "$INSTALL_DIR/" 2>/dev/null || true
fi
# Cleanup
cd - > /dev/null
rm -rf "$TMP_DIR"
echo "Successfully installed SAM (${VERSION}) to ${INSTALL_DIR}"
echo "Run 'sam-node --help' to get started."