-
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 (72 loc) · 2.24 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·84 lines (72 loc) · 2.24 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
#!/usr/bin/env bash
set -e
REPO="halpworld/halpradio"
BIN_NAME="halpradio"
# Detect OS
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
case "${OS}" in
darwin) OS="darwin" ;;
linux) OS="linux" ;;
*)
echo "Error: Unsupported operating system: ${OS}"
echo "halpradio currently supports macOS (Darwin) and Linux."
exit 1
;;
esac
# Detect Architecture
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64|amd64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
*)
echo "Error: Unsupported architecture: ${ARCH}"
echo "halpradio supports x86_64/amd64 and arm64/aarch64."
exit 1
;;
esac
# Get latest release tag if not specified
if [ -z "${VERSION}" ]; then
echo "🔍 Fetching latest halpradio release..."
VERSION=$(curl -s "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "${VERSION}" ]; then
VERSION="v0.6.0"
fi
fi
# Clean version string (e.g. 1.0.0 from v1.0.0)
CLEAN_VERSION="${VERSION#v}"
TARBALL="${BIN_NAME}_${CLEAN_VERSION}_${OS}_${ARCH}.tar.gz"
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${TARBALL}"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "${TMP_DIR}"' EXIT
echo "⬇️ Downloading halpradio ${VERSION} for ${OS}/${ARCH}..."
if ! curl -sSL -f -o "${TMP_DIR}/${TARBALL}" "${DOWNLOAD_URL}"; then
echo "❌ Error downloading from ${DOWNLOAD_URL}"
echo "Please verify the release exists or build from source:"
echo " go install github.com/${REPO}@latest"
exit 1
fi
echo "📦 Extracting binary..."
tar -xzf "${TMP_DIR}/${TARBALL}" -C "${TMP_DIR}"
# Determine installation directory
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
USE_SUDO=""
if [ ! -w "${INSTALL_DIR}" ]; then
if [ -t 0 ] && command -v sudo >/dev/null 2>&1; then
USE_SUDO="sudo"
else
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "${INSTALL_DIR}"
USE_SUDO=""
fi
fi
echo "🚀 Installing halpradio to ${INSTALL_DIR}..."
${USE_SUDO} mv "${TMP_DIR}/${BIN_NAME}" "${INSTALL_DIR}/${BIN_NAME}"
${USE_SUDO} chmod +x "${INSTALL_DIR}/${BIN_NAME}"
echo ""
echo "✅ halpradio ${VERSION} installed successfully!"
echo ""
echo "Quick Start:"
echo " 1. Run: halpradio"
echo " 2. Press ? to open WhichKey help"
echo " 3. Press / to search 30,000+ radio stations"
echo ""