Re-clone bootstrap.sh's target directory when the existing copy is broken

If an existing ~/ubuntu-post-install checkout has a broken/SSH-only
origin remote, `git pull --ff-only` fails and the script fell through
to "continuing with existing version" — even when that existing copy
is missing setup.sh entirely, guaranteeing a crash right after. Now
checks for setup.sh post-pull and wipes + re-clones over HTTPS (no SSH
key needed) if it's still missing.
This commit is contained in:
Claude
2026-07-20 02:39:07 +00:00
parent 8ee35e1995
commit d6261de1e7
+15
View File
@@ -87,6 +87,21 @@ else
fi fi
fi fi
# The pull-failed fallback above assumes the existing checkout is at least
# usable — it isn't always (e.g. a stale/broken .git dir, an origin remote
# pointed at SSH with no key available under sudo, an interrupted first
# clone). Rather than hand the user a guaranteed "setup.sh: No such file or
# directory" crash, treat a missing setup.sh as "this copy is unusable" and
# re-clone fresh over HTTPS (which doesn't need any SSH key at all).
if [ ! -f "$DEST/setup.sh" ]; then
echo " Existing copy at $DEST looks incomplete or broken — re-cloning fresh..."
rm -rf "$DEST"
git clone "$CLONE_URL" "$DEST"
if [ -n "$PAT" ]; then
git -C "$DEST" remote set-url origin "$REPO_URL"
fi
fi
echo "" echo ""
echo " Launching setup..." echo " Launching setup..."
echo "" echo ""