- teardown_all.sh: replace `yes |` pipeline with `< <(yes)` process
substitution to avoid SIGPIPE (exit 141) false failures under pipefail
- phase6_teardown.sh: extract push mirror `.id` instead of `.remote_name`
to match the DELETE /push_mirrors/{id} API contract
- phase5_migrate_pipelines.sh: expand sed regex from `[a-z_]*` to
`[a-z_.]*` to handle nested GitHub contexts like
`github.event.pull_request.number`
- lib/common.sh: render_template now requires explicit variable list to
prevent envsubst from eating Nginx variables ($host, $proxy_add_...)
- backup scripts: remove MacBook relay, use direct Unraid↔Fedora SCP;
fix dump path to write to /data/ (mounted volume) instead of /tmp/
(container-only); add unzip -t integrity verification
- preflight.sh: add --skip-port-checks flag for resuming with
--start-from (ports already bound by earlier phases)
- run_all.sh: update run_step to pass extra args; use --skip-port-checks
when --start-from > 1
- post-checks (phase4/7/9): wrap API calls in helper functions with
>/dev/null redirection instead of passing -o /dev/null as API data
- phase8: replace GitHub archiving with [MIRROR] description marking
and disable wiki/projects/Pages (archived repos reject push mirrors)
- restore_to_primary.sh: add require_vars for Fedora SSH variables
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
88 lines
2.7 KiB
Bash
Executable File
88 lines
2.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# =============================================================================
|
|
# phase8_post_check.sh — Verify Phase 8 (Cutover) succeeded
|
|
# Checks:
|
|
# 1. HTTPS works with valid cert
|
|
# 2. HTTP redirects to HTTPS
|
|
# 3. All repos accessible via HTTPS
|
|
# 4. GitHub repos are marked as offsite backup
|
|
# Exits 0 only if ALL checks pass.
|
|
# =============================================================================
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
source "${SCRIPT_DIR}/lib/common.sh"
|
|
|
|
load_env
|
|
require_vars GITEA_DOMAIN GITEA_ADMIN_TOKEN GITEA_ORG_NAME \
|
|
GITHUB_USERNAME GITHUB_TOKEN \
|
|
REPO_1_NAME REPO_2_NAME REPO_3_NAME
|
|
|
|
log_info "=== Phase 8 Post-Check ==="
|
|
|
|
REPOS=("$REPO_1_NAME" "$REPO_2_NAME" "$REPO_3_NAME")
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
run_check() {
|
|
local description="$1"; shift
|
|
if "$@" 2>/dev/null; then
|
|
log_success "$description"
|
|
PASS=$((PASS + 1))
|
|
else
|
|
log_error "FAIL: $description"
|
|
FAIL=$((FAIL + 1))
|
|
fi
|
|
}
|
|
|
|
# Check 1: HTTPS works
|
|
run_check "HTTPS returns 200 at https://${GITEA_DOMAIN}" \
|
|
curl -sf -o /dev/null "https://${GITEA_DOMAIN}/api/v1/version"
|
|
|
|
# Check 2: HTTP redirects to HTTPS (returns 301)
|
|
check_redirect() {
|
|
local http_code
|
|
http_code=$(curl -sI -o /dev/null -w "%{http_code}" "http://${GITEA_DOMAIN}/")
|
|
[[ "$http_code" == "301" ]]
|
|
}
|
|
run_check "HTTP → HTTPS redirect (301)" check_redirect
|
|
|
|
# Check 3: SSL certificate is valid (not self-signed)
|
|
check_ssl_cert() {
|
|
# Verify openssl can connect and the cert is issued by a recognized CA
|
|
local issuer
|
|
issuer=$(echo | openssl s_client -connect "${GITEA_DOMAIN}:443" -servername "${GITEA_DOMAIN}" 2>/dev/null | openssl x509 -noout -issuer 2>/dev/null || echo "")
|
|
# Check that the issuer is not empty (meaning cert is valid)
|
|
[[ -n "$issuer" ]]
|
|
}
|
|
run_check "SSL certificate is valid" check_ssl_cert
|
|
|
|
# Check 4: All repos accessible via HTTPS
|
|
for repo in "${REPOS[@]}"; do
|
|
run_check "Repo ${repo} accessible at https://${GITEA_DOMAIN}/${GITEA_ORG_NAME}/${repo}" \
|
|
curl -sf -o /dev/null -H "Authorization: token ${GITEA_ADMIN_TOKEN}" "https://${GITEA_DOMAIN}/api/v1/repos/${GITEA_ORG_NAME}/${repo}"
|
|
done
|
|
|
|
# Check 5: GitHub repos are marked as offsite backup
|
|
for repo in "${REPOS[@]}"; do
|
|
check_mirror_marked() {
|
|
local desc
|
|
desc=$(github_api GET "/repos/${GITHUB_USERNAME}/$1" | jq -r '.description // ""')
|
|
[[ "$desc" == "[MIRROR]"* ]]
|
|
}
|
|
run_check "GitHub repo ${repo} marked as mirror" check_mirror_marked "$repo"
|
|
done
|
|
|
|
# Summary
|
|
printf '\n'
|
|
log_info "Results: ${PASS} passed, ${FAIL} failed"
|
|
|
|
if [[ $FAIL -gt 0 ]]; then
|
|
log_error "Phase 8 post-check FAILED"
|
|
exit 1
|
|
else
|
|
log_success "Phase 8 post-check PASSED — Gitea is live with HTTPS"
|
|
exit 0
|
|
fi
|