From 1db7ebfeed7a3e68b12fe484ec7fcbeb21033208 Mon Sep 17 00:00:00 2001 From: master3395 Date: Mon, 26 Jan 2026 20:45:14 +0100 Subject: [PATCH] Improve git clone error handling and fallback logic - Add timeout for git clone (180 seconds) - Better error messages showing actual git errors - Verify repository structure before using cloned repo - Improve fallback installer download with better error handling - Support both yum and dnf for RHEL-based systems --- install.sh | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 26f43b6b9..561629b19 100644 --- a/install.sh +++ b/install.sh @@ -37,13 +37,31 @@ if [[ "$SCRIPT_DIR" == /dev/fd/* ]] || [[ ! -d "$SCRIPT_DIR/modules" ]]; then mkdir -p "$TEMP_DIR" early_log "📦 Cloning CyberPanel repository (branch: $BRANCH_NAME)..." - if git clone --depth 1 --branch "$BRANCH_NAME" https://github.com/master3395/cyberpanel.git "$TEMP_DIR/cyberpanel" 2>/dev/null; then - SCRIPT_DIR="$TEMP_DIR/cyberpanel" - cd "$SCRIPT_DIR" - early_log "✅ Repository cloned successfully" + early_log "This may take a minute depending on your connection speed..." + + # Try git clone with timeout and better error handling + if timeout 120 git clone --depth 1 --branch "$BRANCH_NAME" https://github.com/master3395/cyberpanel.git "$TEMP_DIR/cyberpanel" 2>&1 | tee /tmp/git-clone.log; then + if [ -d "$TEMP_DIR/cyberpanel" ] && [ -f "$TEMP_DIR/cyberpanel/install.sh" ]; then + SCRIPT_DIR="$TEMP_DIR/cyberpanel" + cd "$SCRIPT_DIR" + early_log "✅ Repository cloned successfully" + else + early_log "⚠️ Git clone completed but repository structure is invalid" + early_log "Falling back to legacy installer..." + rm -rf "$TEMP_DIR/cyberpanel" + fi else - # Fallback: try to download install.sh from the old method - early_log "⚠️ Git clone failed, falling back to legacy installer..." + GIT_ERROR=$(cat /tmp/git-clone.log 2>/dev/null | tail -5) + early_log "⚠️ Git clone failed" + if [ -n "$GIT_ERROR" ]; then + early_log "Error details: $GIT_ERROR" + fi + early_log "Falling back to legacy installer..." + rm -rf "$TEMP_DIR/cyberpanel" 2>/dev/null || true + fi + + # If we reach here, git clone failed or was invalid, use fallback + if [ ! -d "$SCRIPT_DIR/modules" ]; then OUTPUT=$(cat /etc/*release 2>/dev/null || echo "") if echo "$OUTPUT" | grep -qE "(CentOS|AlmaLinux|CloudLinux|Rocky)" ; then SERVER_OS="CentOS8"