feat(script): add auto-heal for corrupt git repo

This commit is contained in:
João Pedro Toledo Goncalves 2026-01-27 09:11:30 -03:00
parent 9c4aee8c86
commit 35138518b2
1 changed files with 9 additions and 2 deletions

View File

@ -56,8 +56,15 @@ else
echo "[Pre-Flight] Repository exists. Pulling latest..."
cd "$REPO_DIR"
git config --global --add safe.directory "$REPO_DIR"
git pull
fi
# Attempt pull, if fails (lock file or corruption), wipe and re-clone
if ! git pull; then
echo "[Pre-Flight] ERROR: Git pull failed (likely corrupt ref/lock). Re-cloning..."
cd /
rm -rf "$REPO_DIR"
mkdir -p "$REPO_DIR"
git clone "$GIT_URL" "$REPO_DIR"
fi
# SYMLINK SETUP
# We want Nginx to use the configs from the repo (dynamic) instead of the baked-in ones (static).