-
Notifications
You must be signed in to change notification settings - Fork 1
/
install_tinytools.sh
executable file
·71 lines (59 loc) · 1.76 KB
/
install_tinytools.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# convenience script to downloand and install the current version of tinytools-vty binary
# Define the release version
RELEASE_VERSION="v0.1.0.7"
# Determine the operating system
OS=$(uname -s)
# Determine the OS architecture
ARCH=$(uname -m)
case "$ARCH" in
x86_64)
# 64-bit architecture
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
# Define the base URL
BASE_URL="https://github.com/minimapletinytools/tinytools-vty/releases/download/$RELEASE_VERSION"
# Set the appropriate binary file based on the OS and architecture
case "$OS" in
Darwin*)
# macOS
ZIP_URL="$BASE_URL/tinytools-x86_64-osx.zip"
;;
Linux*)
# Linux
ZIP_URL="$BASE_URL/tinytools-x86_64-linux.zip"
;;
*)
echo "Unsupported operating system: $OS"
exit 1
;;
esac
# Prompt the user for the installation directory
read -p "Enter the installation directory (default: /usr/local/bin): " INSTALL_DIR
INSTALL_DIR=${INSTALL_DIR:-/usr/local/bin}
# Create a temporary directory to download and extract files
TEMP_DIR=$(mktemp -d)
# Function to cleanup temporary directory
cleanup() {
rm -rf "$TEMP_DIR"
}
# Trap the script exit and call the cleanup function
trap cleanup EXIT
# Download and extract the zip file
echo "Downloading and extracting tinytools..."
curl -L "$ZIP_URL" -o "$TEMP_DIR/tinytools.zip"
unzip "$TEMP_DIR/tinytools.zip" -d "$TEMP_DIR"
# Move the binary to the installation directory
echo "Installing tinytools to $INSTALL_DIR..."
if mv "$TEMP_DIR/tinytools" "$INSTALL_DIR/"; then
# Set execute permissions
chmod +x "$INSTALL_DIR/tinytools"
echo "tinytools $RELEASE_VERSION has been successfully installed to $INSTALL_DIR"
else
echo "Error: Failed to move tinytools to $INSTALL_DIR. Installation failed."
exit 1
fi