-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
95 lines (84 loc) · 2.81 KB
/
Copy pathinstall.sh
File metadata and controls
95 lines (84 loc) · 2.81 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
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
set -euo pipefail
# Configuration
APP_NAME="namekit"
INSTALL_DIR="${HOME}/.local/bin"
GITHUB_REPO="namekitapp/namekit"
# Determine system architecture and OS
ARCH=$(uname -m)
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
# Map architectures and OS to release naming
case "$OS" in
linux*)
case "$ARCH" in
x86_64)
ASSET_NAME="namekit-linux-amd64"
BINARY_NAME="namekit"
;;
aarch64|arm64)
ASSET_NAME="namekit-linux-arm64"
BINARY_NAME="namekit"
;;
*)
echo "Unsupported Linux architecture: $ARCH"
exit 1
;;
esac
;;
darwin*)
case "$ARCH" in
x86_64)
ASSET_NAME="namekit-macos-amd64"
BINARY_NAME="namekit"
;;
aarch64|arm64)
ASSET_NAME="namekit-macos-arm64"
BINARY_NAME="namekit"
;;
*)
echo "Unsupported macOS architecture: $ARCH"
exit 1
;;
esac
;;
msys*|mingw*|cygwin*|windows*)
if [ "$ARCH" = "x86_64" ]; then
ASSET_NAME="namekit-windows-amd64"
BINARY_NAME="namekit.exe"
else
echo "Unsupported Windows architecture: $ARCH"
exit 1
fi
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
# Get latest release information from GitHub API
echo "Fetching latest release information..."
RELEASE_INFO=$(curl -s "https://api.github.com/repos/${GITHUB_REPO}/releases/latest")
VERSION=$(echo "$RELEASE_INFO" | grep -o '"tag_name": "[^"]*' | sed 's/"tag_name": "//; s/^v//')
# Set up download URL for the latest release (direct binary, not tar.gz)
DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${ASSET_NAME}"
# Create install directory if it doesn't exist
mkdir -p "$INSTALL_DIR"
# Create temporary directory for download
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
echo "Downloading ${APP_NAME} v${VERSION} for ${OS}/${ARCH}..."
curl -L "$DOWNLOAD_URL" -o "${TMP_DIR}/${BINARY_NAME}"
echo "Installing to ${INSTALL_DIR}..."
cp "${TMP_DIR}/${BINARY_NAME}" "${INSTALL_DIR}/"
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"
# Check if install directory is in PATH
if [[ ":$PATH:" != *":${INSTALL_DIR}:"* ]]; then
echo "Warning: ${INSTALL_DIR} is not in your PATH."
echo "Add the following to your shell configuration file:"
if [[ "$OS" == "msys"* || "$OS" == "mingw"* || "$OS" == "cygwin"* || "$OS" == "windows"* ]]; then
echo "PATH=\"\$PATH:${INSTALL_DIR}\""
else
echo "export PATH=\"\$PATH:${INSTALL_DIR}\""
fi
fi
echo "${APP_NAME} v${VERSION} installed successfully!"