-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·48 lines (38 loc) · 1.33 KB
/
install.sh
File metadata and controls
executable file
·48 lines (38 loc) · 1.33 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
#!/bin/bash
set -e
# Configuration
REPO="JammingBen/opencloud-skill-cli"
BINARY_NAME="oc-cli"
INSTALL_DIR="/usr/local/bin"
# Detect OS
OS_NAME=$(uname -s)
case "${OS_NAME}" in
Darwin*) OS="Darwin" ;;
Linux*) OS="Linux" ;;
*) echo "Error: Unsupported OS ${OS_NAME}. Only Darwin and Linux are supported." && exit 1 ;;
esac
# Detect Architecture
ARCH_NAME=$(uname -m)
case "${ARCH_NAME}" in
x86_64*) ARCH="x86_64" ;;
arm64*|aarch64*) ARCH="arm64" ;;
*) echo "Error: Unsupported architecture ${ARCH_NAME}." && exit 1 ;;
esac
# Construct download URL for the latest release
DOWNLOAD_URL="https://github.com/${REPO}/releases/latest/download/${BINARY_NAME}_${OS}_${ARCH}.tar.gz"
echo "Downloading ${BINARY_NAME} for ${OS} ${ARCH}..."
TEMP_DIR=$(mktemp -d)
curl -sSL "${DOWNLOAD_URL}" -o "${TEMP_DIR}/${BINARY_NAME}.tar.gz"
echo "Extracting..."
tar -xzf "${TEMP_DIR}/${BINARY_NAME}.tar.gz" -C "${TEMP_DIR}"
echo "Installing to ${INSTALL_DIR}..."
if [ -w "${INSTALL_DIR}" ]; then
mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/"
else
echo "Requesting sudo for installation to ${INSTALL_DIR}..."
sudo mv "${TEMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/"
fi
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
rm -rf "${TEMP_DIR}"
echo "Successfully installed ${BINARY_NAME} to ${INSTALL_DIR}"
${BINARY_NAME} version