feat: add Phase 4 — Migrate Repos + Fedora mirrors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
S
2026-02-26 15:21:50 -06:00
parent 6b82752d9e
commit e2ab5ee108
3 changed files with 306 additions and 0 deletions

51
phase4_teardown.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/usr/bin/env bash
set -euo pipefail
# =============================================================================
# phase4_teardown.sh — Delete migrated repos from primary + mirrors from Fedora
# Destructive: permanently deletes repositories.
# Prompts for confirmation before each deletion.
# Safe to run if repos have already been deleted (no errors).
# =============================================================================
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
source "${SCRIPT_DIR}/lib/common.sh"
load_env
require_vars GITEA_ADMIN_TOKEN GITEA_BACKUP_ADMIN_TOKEN \
GITEA_INTERNAL_URL GITEA_BACKUP_INTERNAL_URL \
GITEA_ORG_NAME GITEA_ADMIN_USER \
REPO_1_NAME REPO_2_NAME REPO_3_NAME
log_warn "=== Phase 4 Teardown: Repos + Mirrors ==="
REPOS=("$REPO_1_NAME" "$REPO_2_NAME" "$REPO_3_NAME")
printf 'This will DELETE all migrated repos and mirrors. Continue? [y/N] '
read -r confirm
if [[ ! "$confirm" =~ ^[Yy]$ ]]; then
log_info "Teardown cancelled"
exit 0
fi
for repo in "${REPOS[@]}"; do
log_info "--- Tearing down: ${repo} ---"
# Delete repo from primary (under org)
if gitea_api GET "/repos/${GITEA_ORG_NAME}/${repo}" >/dev/null 2>&1; then
gitea_api DELETE "/repos/${GITEA_ORG_NAME}/${repo}" >/dev/null || true
log_success "Deleted ${GITEA_ORG_NAME}/${repo} from primary"
else
log_info "Repo ${GITEA_ORG_NAME}/${repo} not found on primary — already deleted"
fi
# Delete mirror from Fedora (under admin user)
if gitea_backup_api GET "/repos/${GITEA_ADMIN_USER}/${repo}" >/dev/null 2>&1; then
gitea_backup_api DELETE "/repos/${GITEA_ADMIN_USER}/${repo}" >/dev/null || true
log_success "Deleted mirror ${GITEA_ADMIN_USER}/${repo} from Fedora"
else
log_info "Mirror ${GITEA_ADMIN_USER}/${repo} not found on Fedora — already deleted"
fi
done
log_success "Phase 4 teardown complete"