Skip to content

Commit 47d9a14

Browse files
committed
feat(install): add DEBUG and FORCE_SSH options for git access
- Lower SSH timeout from default to 5 seconds - Add DEBUG=1 env to show detailed error output on SSH failure - Add FORCE_SSH=1 env to fail instead of falling back to HTTPS
1 parent 55ce452 commit 47d9a14

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

install.sh

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ set -e
33

44
# Dotfiles installer script
55
# Usage: curl -sSL fx.github.io/dotfiles/install.sh | sh -s -- [profile]
6+
#
7+
# Environment variables:
8+
# DEBUG=1 - Show detailed error output when git fails
9+
# FORCE_SSH=1 - Fail entirely if SSH doesn't work (no HTTPS fallback)
610

711
# Auto-detect desktop profile if not specified
812
if [ -n "$1" ]; then
@@ -67,14 +71,31 @@ if [ -f "$SCRIPT_DIR/.chezmoiignore" ] && [ -d "$SCRIPT_DIR/.chezmoiscripts" ];
6771
LOCAL_MODE=true
6872
print_success "Using local dotfiles repository at $SCRIPT_DIR"
6973
else
70-
# Test git SSH access by attempting to ls-remote
74+
# Test git SSH access by attempting to ls-remote (5 second timeout)
7175
print_step "Checking Git access..."
72-
if git ls-remote "git@github.com:${DOTFILES_REPO}.git" >/dev/null 2>&1; then
76+
GIT_SSH_ERROR=$(mktemp)
77+
if timeout 5 git ls-remote "git@github.com:${DOTFILES_REPO}.git" >/dev/null 2>"$GIT_SSH_ERROR"; then
7378
DOTFILES_URL="git@github.com:${DOTFILES_REPO}.git"
7479
print_success "Using SSH for dotfiles repository"
80+
rm -f "$GIT_SSH_ERROR"
7581
else
82+
SSH_EXIT_CODE=$?
83+
if [ "${DEBUG:-0}" = "1" ]; then
84+
print_error "SSH git access failed (exit code: $SSH_EXIT_CODE)"
85+
echo "Error output:"
86+
cat "$GIT_SSH_ERROR"
87+
echo ""
88+
fi
89+
rm -f "$GIT_SSH_ERROR"
90+
91+
if [ "${FORCE_SSH:-0}" = "1" ]; then
92+
print_error "SSH access required (FORCE_SSH=1) but SSH failed"
93+
print_info "Run with DEBUG=1 for more details"
94+
exit 1
95+
fi
96+
7697
DOTFILES_URL="https://github.com/${DOTFILES_REPO}.git"
77-
print_warning "Using HTTPS for dotfiles repository"
98+
print_warning "Using HTTPS for dotfiles repository (SSH failed)"
7899
fi
79100
fi
80101

0 commit comments

Comments
 (0)