-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-gloo.sh
65 lines (49 loc) · 1.33 KB
/
install-gloo.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
#!/bin/bash
set -e
set -o pipefail
# Define color codes
GREEN=$(tput setaf 2)
RED=$(tput setaf 1)
RESET=$(tput sgr0)
# Define the URL of the tar.gz file
URL="https://github.com/GlooHQ/homebrew-gloo/releases/download/v0.2.4/gloo-linux-x86_64.tar.gz"
BINARY_NAME="gloo"
LOG_FILE="install_log.txt"
# Create a temporary directory
TEMP_DIR=$(mktemp -d)
# Function to log messages
log_message() {
local message="$1"
local color="$2"
echo "$(date '+%Y-%m-%d %H:%M:%S') - ${color}${message}${RESET}" | tee -a $LOG_FILE
}
# Error trap function
handle_error() {
log_message "Error: An error occurred in the script" $RED
exit 1
}
# Set the error trap
trap 'handle_error' ERR
# Change to temp directory
cd $TEMP_DIR
# Download the tar.gz file
curl -L -O $URL
# Get the file name from the URL
FILENAME=$(basename $URL)
# Unzip the file
tar -xvzf $FILENAME
# Make the binary executable
chmod +x $BINARY_NAME
# Move the binary to your PATH
mv $BINARY_NAME /usr/local/bin/
# Verify installation
if which $BINARY_NAME > /dev/null; then
VERSION=$($BINARY_NAME --version)
log_message "$BINARY_NAME installed successfully, version: $VERSION" $GREEN
else
log_message "Error: Failed to install $BINARY_NAME" $RED
exit 1
fi
# Cleanup temporary directory
rm -rf $TEMP_DIR
log_message "Installation completed successfully" $GREEN