-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·84 lines (69 loc) · 2.14 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·84 lines (69 loc) · 2.14 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
84
#!/bin/sh
# HeadsDown CLI installer
# Usage: curl -fsSL https://headsdown.app/install.sh | sh
#
# Detects OS/arch, downloads the latest release binary from GitHub,
# and installs it to /usr/local/bin (or ~/bin as fallback).
set -e
REPO="headsdownapp/headsdown-cli"
BINARY="hd"
# Detect platform
OS="$(uname -s)"
ARCH="$(uname -m)"
case "$OS" in
Linux) OS_TAG="linux" ;;
Darwin) OS_TAG="darwin" ;;
*) echo "Unsupported OS: $OS"; exit 1 ;;
esac
case "$ARCH" in
x86_64|amd64) ARCH_TAG="x86_64" ;;
aarch64|arm64) ARCH_TAG="aarch64" ;;
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
esac
ARTIFACT="hd-${ARCH_TAG}-${OS_TAG}"
echo ""
echo " HeadsDown CLI installer"
echo ""
echo " Platform: ${OS_TAG}/${ARCH_TAG}"
# Get the latest release tag
echo " Fetching latest release..."
LATEST=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST" ]; then
echo " Error: Could not determine latest release"
exit 1
fi
echo " Version: ${LATEST}"
# Download
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST}/${ARTIFACT}"
echo " Downloading ${ARTIFACT}..."
TMPDIR="${TMPDIR:-/tmp}"
TMPFILE="${TMPDIR}/hd-download-$$"
curl -fsSL -o "$TMPFILE" "$DOWNLOAD_URL"
chmod +x "$TMPFILE"
# Install
INSTALL_DIR="/usr/local/bin"
if [ ! -w "$INSTALL_DIR" ]; then
# Try with sudo
if command -v sudo >/dev/null 2>&1; then
echo " Installing to ${INSTALL_DIR} (requires sudo)..."
sudo mv "$TMPFILE" "${INSTALL_DIR}/${BINARY}"
else
# Fallback to ~/bin
INSTALL_DIR="$HOME/bin"
mkdir -p "$INSTALL_DIR"
mv "$TMPFILE" "${INSTALL_DIR}/${BINARY}"
echo ""
echo " Note: Installed to ~/bin. Make sure it's in your PATH:"
echo " export PATH=\"\$HOME/bin:\$PATH\""
fi
else
mv "$TMPFILE" "${INSTALL_DIR}/${BINARY}"
fi
echo ""
echo " ✓ Installed ${BINARY} ${LATEST} to ${INSTALL_DIR}/${BINARY}"
echo ""
echo " Get started:"
echo " hd auth # authenticate"
echo " hd status # check your status"
echo " hd busy 2h # set yourself to busy"
echo ""