-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·85 lines (67 loc) · 2.02 KB
/
install.sh
File metadata and controls
executable file
·85 lines (67 loc) · 2.02 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
#!/bin/bash
set -e
REPO="fernandoguedes/uatiari"
BINARY_NAME="uatiari"
INSTALL_ROOT="$HOME/.local/share"
INSTALL_DIR="$INSTALL_ROOT/uatiari"
BIN_DIR="$HOME/.local/bin"
# Detect OS and Arch
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
ARCH="$(uname -m)"
if [ "$OS" == "darwin" ]; then
OS="macos"
elif [ "$OS" == "linux" ]; then
OS="linux"
else
echo "Unsupported OS: $OS"
exit 1
fi
if [ "$ARCH" == "x86_64" ]; then
ARCH="x64"
elif [ "$ARCH" == "arm64" ] || [ "$ARCH" == "aarch64" ]; then
ARCH="arm64"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
ASSET_NAME="${BINARY_NAME}-${OS}-${ARCH}.tar.gz"
echo "Detected platform: $OS-$ARCH"
echo "Fetching latest version..."
# Get latest release tag
LATEST_RELEASE=$(curl -s "https://api.github.com/repos/$REPO/releases/latest")
TAG_NAME=$(echo "$LATEST_RELEASE" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$TAG_NAME" ]; then
echo "Error: Could not find latest release."
exit 1
fi
echo "Latest version: $TAG_NAME"
# Find asset URL
DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | grep "browser_download_url" | grep "$ASSET_NAME" | cut -d '"' -f 4)
if [ -z "$DOWNLOAD_URL" ]; then
echo "Error: Could not find package for $ASSET_NAME in release $TAG_NAME."
exit 1
fi
# Download
TMP_FILE="/tmp/${ASSET_NAME}"
echo "Downloading $DOWNLOAD_URL..."
curl -L -o "$TMP_FILE" "$DOWNLOAD_URL"
# Install
echo "Installing to $INSTALL_DIR..."
mkdir -p "$INSTALL_ROOT"
mkdir -p "$BIN_DIR"
if [ -d "$INSTALL_DIR" ]; then
rm -rf "$INSTALL_DIR"
fi
tar -xzf "$TMP_FILE" -C "$INSTALL_ROOT"
rm "$TMP_FILE"
# Symlink
echo "Creating symlink in $BIN_DIR..."
ln -sf "$INSTALL_DIR/$BINARY_NAME" "$BIN_DIR/$BINARY_NAME"
# Check PATH
if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
echo "⚠️ Warning: $BIN_DIR is not in your PATH."
echo "Add the following line to your shell configuration (.zshrc, .bashrc):"
echo "export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
echo "Successfully installed $BINARY_NAME $TAG_NAME!"
echo "Run '$BINARY_NAME --help' to get started."