-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·73 lines (57 loc) · 1.87 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·73 lines (57 loc) · 1.87 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
#!/bin/sh
set -e
REPO="deckplane/deckplane-cli"
BIN_NAME="deckplane"
# Determine OS
OS="$(uname -s)"
case "${OS}" in
Linux*) OS_NAME=linux;;
Darwin*) OS_NAME=darwin;;
CYGWIN*|MINGW*|MSYS*) OS_NAME=windows;;
*) echo "Unsupported OS: ${OS}"; exit 1;;
esac
# Determine architecture
ARCH="$(uname -m)"
case "${ARCH}" in
x86_64*|amd64*) ARCH_NAME=amd64;;
aarch64*|arm64*) ARCH_NAME=arm64;;
*) echo "Unsupported architecture: ${ARCH}"; exit 1;;
esac
TARGET="${OS_NAME}-${ARCH_NAME}"
EXT=""
if [ "${OS_NAME}" = "windows" ]; then
EXT=".exe"
fi
echo "Detecting latest release..."
LATEST_URL="https://api.github.com/repos/${REPO}/releases/latest"
VERSION=$(curl -sL $LATEST_URL | grep '"tag_name":' | cut -d '"' -f 4)
if [ -z "$VERSION" ]; then
echo "Failed to fetch latest version from GitHub."
echo "You may have hit the GitHub API rate limit."
exit 1
fi
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${BIN_NAME}-${TARGET}${EXT}"
TMP_DIR="$(mktemp -d)"
TMP_BIN="${TMP_DIR}/${BIN_NAME}${EXT}"
echo "Downloading ${BIN_NAME} ${VERSION} for ${TARGET}..."
curl -sL "${DOWNLOAD_URL}" -o "${TMP_BIN}"
chmod +x "${TMP_BIN}"
INSTALL_DIR="/usr/local/bin"
if [ "${OS_NAME}" = "windows" ]; then
INSTALL_DIR="${HOME}/bin"
mkdir -p "${INSTALL_DIR}"
fi
echo "Installing to ${INSTALL_DIR}..."
# Check if we can write to the install directory
if [ -w "${INSTALL_DIR}" ]; then
mv "${TMP_BIN}" "${INSTALL_DIR}/${BIN_NAME}${EXT}"
else
echo "Administrator privileges required to write to ${INSTALL_DIR}."
sudo mv "${TMP_BIN}" "${INSTALL_DIR}/${BIN_NAME}${EXT}"
fi
rm -rf "${TMP_DIR}"
echo ""
echo "Successfully installed ${BIN_NAME} to ${INSTALL_DIR}/${BIN_NAME}${EXT}"
if [ "${OS_NAME}" = "windows" ] || ! command -v "${BIN_NAME}" >/dev/null 2>&1; then
echo "Make sure ${INSTALL_DIR} is in your PATH."
fi