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:
@@ -87,6 +87,21 @@ else
|
||||
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 " Launching setup..."
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user