-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·41 lines (29 loc) · 1.13 KB
/
install.sh
File metadata and controls
executable file
·41 lines (29 loc) · 1.13 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
#!/bin/sh
set -e
# Define variables
REPO="bakito/toolbox"
INSTALL_DIR="$HOME/bin"
BIN_NAME="toolbox"
# Ensure the installation directory exists
mkdir -p "$INSTALL_DIR"
# Get the latest release tag
LATEST_TAG=$(curl -sSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | cut -d '"' -f 4)
# Construct download URL
ARCHIVE_NAME="${BIN_NAME}_${LATEST_TAG#v}_linux_amd64.tar.gz"
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$LATEST_TAG/$ARCHIVE_NAME"
# Temporary directory for extraction
TMP_DIR=$(mktemp -d)
# Download the archive
echo "$(date '+%Y/%m/%d %H:%M:%S') 🧰 Downloading $BIN_NAME version $LATEST_TAG..."
curl -sSL "$DOWNLOAD_URL" -o "$TMP_DIR/$ARCHIVE_NAME"
# Extract the archive
tar -xzf "$TMP_DIR/$ARCHIVE_NAME" -C "$TMP_DIR"
# Move the binary to the install directory
mv "$TMP_DIR/$BIN_NAME" "$INSTALL_DIR/"
# Make it executable
chmod +x "$INSTALL_DIR/$BIN_NAME"
# Clean up
rm -rf "$TMP_DIR"
# Print success message
echo "$(date '+%Y/%m/%d %H:%M:%S') 🚀 $BIN_NAME installed successfully to $INSTALL_DIR"
echo "$(date '+%Y/%m/%d %H:%M:%S') Add $INSTALL_DIR to your PATH if not already included"