-
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 (69 loc) · 2.3 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·83 lines (69 loc) · 2.3 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.sh — download and install the latest bsky-cli binary
# Usage: curl -fsSL https://raw.githubusercontent.com/harveyrandall/bsky-cli/main/install.sh | sh
set -e
REPO="harveyrandall/bsky-cli"
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
BINARY="bsky"
# Detect OS
OS="$(uname -s)"
case "$OS" in
Darwin) os="macos" ;;
Linux) os="linux" ;;
*)
echo "Error: unsupported OS: $OS" >&2
exit 1
;;
esac
# Detect architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64|amd64) arch="x64" ;;
arm64|aarch64) arch="arm64" ;;
*)
echo "Error: unsupported architecture: $ARCH" >&2
exit 1
;;
esac
ARTIFACT="bsky-${os}-${arch}"
# Get latest release tag
TAG="$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')"
if [ -z "$TAG" ]; then
echo "Error: could not determine latest release" >&2
exit 1
fi
URL="https://github.com/${REPO}/releases/download/${TAG}/${ARTIFACT}.tar.gz"
CHECKSUM_URL="https://github.com/${REPO}/releases/download/${TAG}/checksums.txt"
echo "Downloading ${BINARY} ${TAG} for ${os}/${arch}..."
TMPDIR="$(mktemp -d)"
trap 'rm -rf "$TMPDIR"' EXIT
curl -fsSL "$URL" -o "${TMPDIR}/${ARTIFACT}.tar.gz"
curl -fsSL "$CHECKSUM_URL" -o "${TMPDIR}/checksums.txt"
# Verify checksum
EXPECTED="$(grep "${ARTIFACT}.tar.gz" "${TMPDIR}/checksums.txt" | awk '{print $1}')"
if [ -n "$EXPECTED" ]; then
if command -v sha256sum >/dev/null 2>&1; then
ACTUAL="$(sha256sum "${TMPDIR}/${ARTIFACT}.tar.gz" | awk '{print $1}')"
elif command -v shasum >/dev/null 2>&1; then
ACTUAL="$(shasum -a 256 "${TMPDIR}/${ARTIFACT}.tar.gz" | awk '{print $1}')"
else
echo "Warning: no sha256sum or shasum found, skipping checksum verification" >&2
ACTUAL="$EXPECTED"
fi
if [ "$ACTUAL" != "$EXPECTED" ]; then
echo "Error: checksum mismatch" >&2
echo " expected: $EXPECTED" >&2
echo " actual: $ACTUAL" >&2
exit 1
fi
fi
# Extract and install
tar -xzf "${TMPDIR}/${ARTIFACT}.tar.gz" -C "$TMPDIR"
chmod +x "${TMPDIR}/${BINARY}"
if [ -w "$INSTALL_DIR" ]; then
mv "${TMPDIR}/${BINARY}" "${INSTALL_DIR}/${BINARY}"
else
echo "Installing to ${INSTALL_DIR} (requires sudo)..."
sudo mv "${TMPDIR}/${BINARY}" "${INSTALL_DIR}/${BINARY}"
fi
echo "Installed ${BINARY} ${TAG} to ${INSTALL_DIR}/${BINARY}"