|
9 | 9 | # VERSION - Install specific API version (default: latest) |
10 | 10 | # CLI_VERSION - Install specific CLI version (default: latest) |
11 | 11 | # BRANCH - Build from source using this branch (for development/testing) |
| 12 | +# BINARY_DIR - Use binaries from this directory instead of building/downloading |
12 | 13 | # INSTALL_DIR - Binary installation directory (default: /opt/hypeman/bin) |
13 | 14 | # DATA_DIR - Data directory (default: /var/lib/hypeman) |
14 | 15 | # CONFIG_DIR - Config directory (default: /etc/hypeman) |
@@ -99,13 +100,30 @@ command -v systemctl >/dev/null 2>&1 || error "systemctl is required but not ins |
99 | 100 | command -v setcap >/dev/null 2>&1 || error "setcap is required but not installed (install libcap2-bin)" |
100 | 101 | command -v openssl >/dev/null 2>&1 || error "openssl is required but not installed" |
101 | 102 |
|
| 103 | +# Count how many of BRANCH, VERSION, BINARY_DIR are set |
| 104 | +count=0 |
| 105 | +[ -n "$BRANCH" ] && ((count++)) |
| 106 | +[ -n "$VERSION" ] && ((count++)) |
| 107 | +[ -n "$BINARY_DIR" ] && ((count++)) |
| 108 | + |
| 109 | +if [ "$count" -gt 1 ]; then |
| 110 | + error "BRANCH, VERSION, and BINARY_DIR are mutually exclusive" |
| 111 | +fi |
| 112 | + |
102 | 113 | # Additional checks for build-from-source mode |
103 | 114 | if [ -n "$BRANCH" ]; then |
104 | 115 | command -v git >/dev/null 2>&1 || error "git is required for BRANCH mode but not installed" |
105 | 116 | command -v go >/dev/null 2>&1 || error "go is required for BRANCH mode but not installed" |
106 | 117 | command -v make >/dev/null 2>&1 || error "make is required for BRANCH mode but not installed" |
107 | 118 | fi |
108 | 119 |
|
| 120 | +# Additional checks for BINARY_DIR mode |
| 121 | +if [ -n "$BINARY_DIR" ]; then |
| 122 | + if [ ! -d "$BINARY_DIR" ]; then |
| 123 | + error "BINARY_DIR does not exist: ${BINARY_DIR}. Are you sure you provided the correct path?" |
| 124 | + fi |
| 125 | +fi |
| 126 | + |
109 | 127 | # Detect OS |
110 | 128 | OS=$(uname -s | tr '[:upper:]' '[:lower:]') |
111 | 129 | if [ "$OS" != "linux" ]; then |
@@ -184,10 +202,25 @@ TMP_DIR=$(mktemp -d) |
184 | 202 | trap "rm -rf $TMP_DIR" EXIT |
185 | 203 |
|
186 | 204 | # ============================================================================= |
187 | | -# Get binaries (either download release or build from source) |
| 205 | +# Get binaries (either use BINARY_DIR, download release, or build from source) |
188 | 206 | # ============================================================================= |
189 | 207 |
|
190 | | -if [ -n "$BRANCH" ]; then |
| 208 | +if [ -n "$BINARY_DIR" ]; then |
| 209 | + # Use binaries from specified directory |
| 210 | + info "Using binaries from ${BINARY_DIR}..." |
| 211 | + |
| 212 | + # Copy binaries to TMP_DIR |
| 213 | + info "Copying binaries from ${BINARY_DIR}..." |
| 214 | + cp "${BINARY_DIR}/${BINARY_NAME}" "${TMP_DIR}/${BINARY_NAME}" |
| 215 | + cp "${BINARY_DIR}/hypeman-token" "${TMP_DIR}/hypeman-token" |
| 216 | + cp "${BINARY_DIR}/.env.example" "${TMP_DIR}/.env.example" |
| 217 | + |
| 218 | + # Make binaries executable |
| 219 | + chmod +x "${TMP_DIR}/${BINARY_NAME}" |
| 220 | + chmod +x "${TMP_DIR}/hypeman-token" |
| 221 | + |
| 222 | + VERSION="custom (from binary)" |
| 223 | +elif [ -n "$BRANCH" ]; then |
191 | 224 | # Build from source mode |
192 | 225 | info "Building from source (branch: $BRANCH)..." |
193 | 226 |
|
@@ -405,7 +438,7 @@ $SUDO systemctl start "$SERVICE_NAME" |
405 | 438 |
|
406 | 439 | CLI_REPO="kernel/hypeman-cli" |
407 | 440 |
|
408 | | -if [ -z "$CLI_VERSION" ]; then |
| 441 | +if [ -z "$CLI_VERSION" ] || [ "$CLI_VERSION" == "latest" ]; then |
409 | 442 | info "Fetching latest CLI version with available artifacts..." |
410 | 443 | CLI_VERSION=$(find_release_with_artifact "$CLI_REPO" "hypeman" "$OS" "$ARCH") |
411 | 444 | if [ -z "$CLI_VERSION" ]; then |
|
0 commit comments