-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·65 lines (53 loc) · 1.64 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
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
APPLICATION_NAME="rr"
INSTALL_PATH="/Users/nbr/.local/bin/"
LAYOUTS_DIR="layouts"
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
ORANGE='\033[0;33m'
NC='\033[0m' # No Color
SYMBOL_POSITIVE=""
SYMBOL_NEGATIVE=""
SYMBOL_INFO=""
SYMBOL_QUESTION=""
SYMBOL_SEPARATOR=" "
print_positive() {
printf "${GREEN}${SYMBOL_POSITIVE}${SYMBOL_SEPARATOR}%s${NC}\n" "$1"
}
print_info() {
printf "${BLUE}${SYMBOL_INFO}${SYMBOL_SEPARATOR}%s${NC}\n" "$1"
}
print_negative() {
printf "${RED}${SYMBOL_NEGATIVE}${SYMBOL_SEPARATOR}%s${NC}\n" "$1"
}
print_question() {
printf "${ORANGE}${SYMBOL_QUESTION}${SYMBOL_SEPARATOR}%s${NC}\n" "$1"
}
# Check if required commands are available
for cmd in go sudo; do
if ! command -v "$cmd" &>/dev/null; then
print_negative "The required command '$cmd' is not installed."
exit 1
fi
done
# Build the Go application
print_info "Building the Go application..."
if ! go build -o "$APPLICATION_NAME"; then
print_negative "Build failed."
exit 1
fi
# Move the binary to the install path
print_info "Moving the binary to '$INSTALL_PATH'..."
if ! sudo mv "$APPLICATION_NAME" "$INSTALL_PATH"; then
print_negative "Failed to move the binary to '$INSTALL_PATH'. Please check your permissions."
exit 1
fi
# Set execute permissions on the layouts directory
print_info "Setting execute permissions on the layouts directory..."
if ! sudo chmod -R +x "$LAYOUTS_DIR"; then
print_negative "Failed to set execute permissions on the '$LAYOUTS_DIR' directory."
exit 1
fi
print_positive "Build and installation successful."
print_info "You can now run the application globally using the command '$APPLICATION_NAME'."