-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·86 lines (71 loc) · 2.28 KB
/
build.sh
File metadata and controls
executable file
·86 lines (71 loc) · 2.28 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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
# Termius From Walmart Build Script
# This script builds the termius-from-walmart application
set -e
echo "================================"
echo "Termius From Walmart Build Script"
echo "================================"
echo ""
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Check if Go is installed
if ! command -v go &> /dev/null; then
echo -e "${RED}Error: Go is not installed${NC}"
echo "Please install Go from https://golang.org/dl/"
exit 1
fi
echo -e "${GREEN}✓ Go is installed$(go version)${NC}"
# Check Go version
GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//')
REQUIRED_VERSION="1.21"
if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$GO_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
echo -e "${RED}Error: Go version $REQUIRED_VERSION or higher is required${NC}"
echo "Current version: $GO_VERSION"
exit 1
fi
echo -e "${GREEN}✓ Go version is compatible${NC}"
echo ""
# Download dependencies
echo "Downloading dependencies..."
go mod download
if [ $? -eq 0 ]; then
echo -e "${GREEN}✓ Dependencies downloaded${NC}"
else
echo -e "${RED}✗ Failed to download dependencies${NC}"
exit 1
fi
# Tidy up go.mod
echo "Tidying dependencies..."
go mod tidy
echo ""
# Build the application
echo "Building termius-from-walmart..."
go build -o termius-from-walmart
if [ $? -eq 0 ]; then
echo ""
echo -e "${GREEN}✓ Build successful!${NC}"
echo ""
echo "The binary 'termius-from-walmart' has been created in the current directory."
echo ""
echo "To run: ./termius-from-walmart"
echo "To install: sudo mv termius-from-walmart /usr/local/bin/"
echo ""
# Check if sshpass is installed
if ! command -v sshpass &> /dev/null; then
echo -e "${YELLOW}Note: 'sshpass' is not installed.${NC}"
echo "For password-based SSH connections, install sshpass:"
echo " Ubuntu/Debian: sudo apt-get install sshpass"
echo " macOS: brew install hudochenkov/sshpass/sshpass"
echo " Fedora: sudo dnf install sshpass"
echo ""
echo "Alternatively, use SSH keys (recommended)."
else
echo -e "${GREEN}✓ sshpass is installed${NC}"
fi
else
echo -e "${RED}✗ Build failed${NC}"
exit 1
fi