|
3 | 3 |
|
4 | 4 | # Dotfiles installer script |
5 | 5 | # 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) |
6 | 10 |
|
7 | 11 | # Auto-detect desktop profile if not specified |
8 | 12 | if [ -n "$1" ]; then |
@@ -67,14 +71,31 @@ if [ -f "$SCRIPT_DIR/.chezmoiignore" ] && [ -d "$SCRIPT_DIR/.chezmoiscripts" ]; |
67 | 71 | LOCAL_MODE=true |
68 | 72 | print_success "Using local dotfiles repository at $SCRIPT_DIR" |
69 | 73 | else |
70 | | - # Test git SSH access by attempting to ls-remote |
| 74 | + # Test git SSH access by attempting to ls-remote (5 second timeout) |
71 | 75 | 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 |
73 | 78 | DOTFILES_URL="git@github.com:${DOTFILES_REPO}.git" |
74 | 79 | print_success "Using SSH for dotfiles repository" |
| 80 | + rm -f "$GIT_SSH_ERROR" |
75 | 81 | 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 | + |
76 | 97 | 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)" |
78 | 99 | fi |
79 | 100 | fi |
80 | 101 |
|
|
0 commit comments