-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·152 lines (135 loc) · 5.46 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·152 lines (135 loc) · 5.46 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
set -e
# Pax8 CTA CLI Installation Script
# Usage: curl -fsSL https://raw.githubusercontent.com/pax8labs/pax8-cta/main/install.sh | bash
REPO="pax8labs/pax8-cta"
VERSION="latest"
INSTALL_DIR="${PAX8_CTA_INSTALL_DIR:-/usr/local/bin}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Detect platform
OS=$(uname -s)
ARCH=$(uname -m)
echo -e "${BLUE}╔═══════════════════════════════════════╗${NC}"
echo -e "${BLUE}║ Pax8 CTA CLI Installer ║${NC}"
echo -e "${BLUE}╚═══════════════════════════════════════╝${NC}"
echo ""
# Determine binary name
if [ "$OS" = "Darwin" ]; then
if [ "$ARCH" = "arm64" ]; then
BINARY="pax8-cta-macos-arm64"
echo -e "${GREEN}✓${NC} Platform: macOS (Apple Silicon)"
elif [ "$ARCH" = "x86_64" ]; then
BINARY="pax8-cta-macos-x64"
echo -e "${GREEN}✓${NC} Platform: macOS (Intel)"
else
echo -e "${RED}✗${NC} Unsupported macOS architecture: $ARCH"
exit 1
fi
elif [ "$OS" = "Linux" ]; then
if [ "$ARCH" = "x86_64" ]; then
BINARY="pax8-cta-linux-x64"
echo -e "${GREEN}✓${NC} Platform: Linux (x64)"
elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
BINARY="pax8-cta-linux-arm64"
echo -e "${GREEN}✓${NC} Platform: Linux (ARM64)"
else
echo -e "${RED}✗${NC} Unsupported Linux architecture: $ARCH"
exit 1
fi
else
echo -e "${RED}✗${NC} Unsupported operating system: $OS"
echo -e "${YELLOW}→${NC} For Windows, download from: https://github.com/$REPO/releases"
exit 1
fi
# Get latest version if not specified
if [ "$VERSION" = "latest" ]; then
echo -e "${BLUE}→${NC} Fetching latest version..."
VERSION=$(curl -sSL "https://api.github.com/repos/$REPO/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
if [ -z "$VERSION" ]; then
echo -e "${RED}✗${NC} Failed to fetch latest version"
exit 1
fi
echo -e "${GREEN}✓${NC} Latest version: $VERSION"
fi
# Download URL
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/$BINARY"
CHECKSUM_URL="https://github.com/$REPO/releases/download/$VERSION/$BINARY.sha256"
# Create temporary directory
TMP_DIR=$(mktemp -d)
trap "rm -rf $TMP_DIR" EXIT
echo -e "${BLUE}→${NC} Downloading Pax8 CTA CLI..."
if ! curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DIR/pax8-cta"; then
echo -e "${RED}✗${NC} Failed to download binary"
echo -e "${YELLOW}→${NC} URL: $DOWNLOAD_URL"
exit 1
fi
echo -e "${GREEN}✓${NC} Downloaded successfully"
# Download and verify checksum
# Compare hashes directly rather than running `sha256sum -c` against the
# .sha256 file: the file references the platform-suffixed filename (e.g.
# `pax8-cta-macos-arm64`) but we've renamed our local copy to `pax8-cta`,
# so a filename-based check would fail.
echo -e "${BLUE}→${NC} Verifying checksum..."
if curl -fsSL "$CHECKSUM_URL" -o "$TMP_DIR/pax8-cta.sha256" 2>/dev/null; then
EXPECTED_HASH=$(awk '{print $1}' "$TMP_DIR/pax8-cta.sha256" | tr '[:upper:]' '[:lower:]')
if command -v sha256sum &> /dev/null; then
ACTUAL_HASH=$(sha256sum "$TMP_DIR/pax8-cta" | awk '{print $1}' | tr '[:upper:]' '[:lower:]')
elif command -v shasum &> /dev/null; then
ACTUAL_HASH=$(shasum -a 256 "$TMP_DIR/pax8-cta" | awk '{print $1}' | tr '[:upper:]' '[:lower:]')
else
echo -e "${YELLOW}⚠${NC} sha256sum not found, skipping checksum verification"
ACTUAL_HASH=""
EXPECTED_HASH=""
fi
if [ -n "$EXPECTED_HASH" ]; then
if [ "$ACTUAL_HASH" != "$EXPECTED_HASH" ]; then
echo -e "${RED}✗${NC} Checksum verification failed"
echo -e "${YELLOW}→${NC} Expected: $EXPECTED_HASH"
echo -e "${YELLOW}→${NC} Actual: $ACTUAL_HASH"
exit 1
fi
echo -e "${GREEN}✓${NC} Checksum verified"
fi
else
echo -e "${YELLOW}⚠${NC} Checksum not available, skipping verification"
fi
# Make executable
chmod +x "$TMP_DIR/pax8-cta"
# Install
echo -e "${BLUE}→${NC} Installing to $INSTALL_DIR..."
# Check if we need sudo
if [ -w "$INSTALL_DIR" ]; then
mv "$TMP_DIR/pax8-cta" "$INSTALL_DIR/pax8-cta"
else
echo -e "${YELLOW}→${NC} Requesting sudo permissions to install to $INSTALL_DIR"
sudo mv "$TMP_DIR/pax8-cta" "$INSTALL_DIR/pax8-cta"
fi
echo -e "${GREEN}✓${NC} Installed successfully"
echo ""
# Verify installation
if command -v pax8-cta &> /dev/null; then
INSTALLED_VERSION=$(pax8-cta --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
echo -e "${GREEN}╔═══════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Installation Complete! ║${NC}"
echo -e "${GREEN}╚═══════════════════════════════════════╝${NC}"
echo ""
echo -e "${BLUE}Version:${NC} $INSTALLED_VERSION"
echo -e "${BLUE}Location:${NC} $(which pax8-cta)"
echo ""
echo -e "${BLUE}Get Started:${NC}"
echo -e " pax8-cta --help"
echo -e " pax8-cta tenants list"
echo -e " pax8-cta deploy --help"
else
echo -e "${YELLOW}⚠${NC} Installation succeeded but 'pax8-cta' not found in PATH"
echo -e "${YELLOW}→${NC} Add $INSTALL_DIR to your PATH:"
echo -e " export PATH=\"$INSTALL_DIR:\$PATH\""
fi
echo ""
echo -e "${BLUE}Documentation:${NC} https://github.com/$REPO"
echo -e "${BLUE}Issues:${NC} https://github.com/$REPO/issues"