Skip to content

Commit e3c2dd0

Browse files
ranjith-srcclaude
andcommitted
Fix install.sh: fall back to main branch if release asset missing
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8e1c328 commit e3c2dd0

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

install.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ echo "Installing ${BINARY_NAME}..."
2020
LATEST_TAG=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" 2>/dev/null \
2121
| grep '"tag_name"' | sed 's/.*"\(.*\)".*/\1/' || true)
2222

23+
DOWNLOADED=false
24+
2325
if [[ -n "$LATEST_TAG" ]]; then
2426
echo "Latest release: ${LATEST_TAG}"
25-
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${LATEST_TAG}/vps-harden.sh"
26-
else
27-
echo "No releases found, downloading from main branch..."
28-
DOWNLOAD_URL="https://raw.githubusercontent.com/${REPO}/main/vps-harden.sh"
27+
RELEASE_URL="https://github.com/${REPO}/releases/download/${LATEST_TAG}/vps-harden.sh"
28+
if curl -fsSL "$RELEASE_URL" -o "${INSTALL_DIR}/${BINARY_NAME}" 2>/dev/null; then
29+
DOWNLOADED=true
30+
fi
2931
fi
3032

31-
# Download
32-
if ! curl -fsSL "$DOWNLOAD_URL" -o "${INSTALL_DIR}/${BINARY_NAME}"; then
33-
echo "Error: Failed to download ${BINARY_NAME}" >&2
34-
exit 1
33+
if [[ "$DOWNLOADED" != "true" ]]; then
34+
echo "Downloading from main branch..."
35+
if ! curl -fsSL "https://raw.githubusercontent.com/${REPO}/main/vps-harden.sh" -o "${INSTALL_DIR}/${BINARY_NAME}"; then
36+
echo "Error: Failed to download ${BINARY_NAME}" >&2
37+
exit 1
38+
fi
3539
fi
3640

3741
chmod +x "${INSTALL_DIR}/${BINARY_NAME}"

0 commit comments

Comments
 (0)