From a2a388a81bce64637c2a2ef4cfb09aff56c617a1 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Sat, 20 Jun 2026 13:59:57 +0530 Subject: [PATCH] feat: Added github fallback --- VERSION | 2 +- routes.sh | 26 ++++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 21e8796..ee90284 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.3 +1.0.4 diff --git a/routes.sh b/routes.sh index a6a82e0..af3d37e 100755 --- a/routes.sh +++ b/routes.sh @@ -55,14 +55,36 @@ for script in "${SCRIPTS[@]}"; do if [ -f "$local_installer" ]; then bash "$local_installer" "$@" else + BOOTSTRAP_BASE_URL="${BOOTSTRAP_BASE_URL:-https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master}" + BOOTSTRAP_FALLBACK_URL="${BOOTSTRAP_FALLBACK_URL:-https://raw.githubusercontent.com/sortedcord/bootstrap/refs/heads/master}" + installer_path="installers/install_${script}.sh" + download_status=0 + if has_command curl; then - curl -fsSL "https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/installers/install_${script}.sh" | bash -s -- "$@" + curl -fsSL "${BOOTSTRAP_BASE_URL}/${installer_path}" | bash -s -- "$@" + download_status="${PIPESTATUS[0]}" + if [ "$download_status" -ne 0 ]; then + log_warn "Failed to download installer from primary URL, trying fallback..." + curl -fsSL "${BOOTSTRAP_FALLBACK_URL}/${installer_path}" | bash -s -- "$@" + download_status="${PIPESTATUS[0]}" + fi elif has_command wget; then - wget -qO- "https://git.adityagupta.dev/sortedcord/bootstrap/raw/branch/master/installers/install_${script}.sh" | bash -s -- "$@" + wget -qO- "${BOOTSTRAP_BASE_URL}/${installer_path}" | bash -s -- "$@" + download_status="${PIPESTATUS[0]}" + if [ "$download_status" -ne 0 ]; then + log_warn "Failed to download installer from primary URL, trying fallback..." + wget -qO- "${BOOTSTRAP_FALLBACK_URL}/${installer_path}" | bash -s -- "$@" + download_status="${PIPESTATUS[0]}" + fi else log_error "Neither curl nor wget is installed to download the installer." exit 1 fi + + if [ "$download_status" -ne 0 ]; then + log_error "Failed to download the installer from both primary and fallback URLs." + exit 1 + fi fi else