-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall.sh
executable file
·55 lines (45 loc) · 1.61 KB
/
install.sh
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
#!/bin/bash
set -e
# Define variables
GITHUB_REPO="fargusplumdoodle/dump_dir"
BINARY_NAME="dump_dir"
INSTALL_DIR="/usr/local/bin"
# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
case $ARCH in
x86_64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) echo "❌ Unsupported architecture: $ARCH"; exit 1 ;;
esac
# Fetch the latest release version
echo "🔍 Fetching the latest release of $BINARY_NAME..."
LATEST_RELEASE=$(curl -sL "https://api.github.com/repos/$GITHUB_REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$LATEST_RELEASE" ]; then
echo "❌ Failed to fetch the latest release. Please check your internet connection and try again."
exit 1
fi
echo "🎉 Latest release: $LATEST_RELEASE"
# Construct the download URL
DOWNLOAD_URL="https://github.com/$GITHUB_REPO/releases/download/$LATEST_RELEASE/${BINARY_NAME}_${OS}_${ARCH}"
# Download the binary
echo "📥 Downloading $BINARY_NAME..."
curl -sL "$DOWNLOAD_URL" -o "$BINARY_NAME"
# Make the binary executable
chmod +x "$BINARY_NAME"
# Install the binary
echo "🚀 Installing $BINARY_NAME to $INSTALL_DIR..."
if [ -w "$INSTALL_DIR" ]; then
mv "$BINARY_NAME" "$INSTALL_DIR"
else
sudo mv "$BINARY_NAME" "$INSTALL_DIR"
fi
# Verify installation
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
echo "✅ $BINARY_NAME has been successfully installed to $INSTALL_DIR"
echo "🎈 You can now use it by running: $BINARY_NAME"
echo "🌟 Happy coding with dump_dir! 🚀📂✨"
else
echo "❌ Installation failed. Please try again or install manually."
exit 1
fi