fix: address multiple bugs from code review
- 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>
This commit is contained in:
54
preflight.sh
54
preflight.sh
@@ -4,11 +4,22 @@ set -euo pipefail
|
||||
# =============================================================================
|
||||
# preflight.sh — Validate everything before running migration phases
|
||||
# Installs nothing. Exits 0 only if ALL checks pass.
|
||||
#
|
||||
# Usage:
|
||||
# ./preflight.sh # Run all checks
|
||||
# ./preflight.sh --skip-port-checks # Skip port-free checks (for --start-from)
|
||||
# =============================================================================
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
source "${SCRIPT_DIR}/lib/common.sh"
|
||||
|
||||
SKIP_PORT_CHECKS=false
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--skip-port-checks) SKIP_PORT_CHECKS=true ;;
|
||||
esac
|
||||
done
|
||||
|
||||
log_info "=== Preflight Checks ==="
|
||||
|
||||
PASS_COUNT=0
|
||||
@@ -204,26 +215,33 @@ fi
|
||||
# Check 13: Port free on Unraid
|
||||
# Uses ss (socket statistics) to check if any process is listening on the port.
|
||||
# The ! negates the grep — we PASS if the port is NOT found in use.
|
||||
# Skipped when --skip-port-checks is set (e.g. resuming with --start-from
|
||||
# after phases 1-2 have Gitea already running on these ports).
|
||||
# ---------------------------------------------------------------------------
|
||||
check_port_unraid() {
|
||||
local port="${UNRAID_GITEA_PORT:-3000}"
|
||||
! ssh_exec UNRAID "ss -tlnp | grep -q ':${port} '" 2>/dev/null
|
||||
}
|
||||
check 13 "Port ${UNRAID_GITEA_PORT:-3000} free on Unraid" check_port_unraid
|
||||
if ! check_port_unraid 2>/dev/null; then
|
||||
log_error " → Port ${UNRAID_GITEA_PORT:-3000} already in use on Unraid."
|
||||
fi
|
||||
if [[ "$SKIP_PORT_CHECKS" == "true" ]]; then
|
||||
log_info "[13] Port ${UNRAID_GITEA_PORT:-3000} free on Unraid — SKIPPED (--skip-port-checks)"
|
||||
log_info "[14] Port ${FEDORA_GITEA_PORT:-3000} free on Fedora — SKIPPED (--skip-port-checks)"
|
||||
else
|
||||
check_port_unraid() {
|
||||
local port="${UNRAID_GITEA_PORT:-3000}"
|
||||
! ssh_exec UNRAID "ss -tlnp | grep -q ':${port} '" 2>/dev/null
|
||||
}
|
||||
check 13 "Port ${UNRAID_GITEA_PORT:-3000} free on Unraid" check_port_unraid
|
||||
if ! check_port_unraid 2>/dev/null; then
|
||||
log_error " → Port ${UNRAID_GITEA_PORT:-3000} already in use on Unraid."
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Check 14: Port free on Fedora
|
||||
# ---------------------------------------------------------------------------
|
||||
check_port_fedora() {
|
||||
local port="${FEDORA_GITEA_PORT:-3000}"
|
||||
! ssh_exec FEDORA "ss -tlnp | grep -q ':${port} '" 2>/dev/null
|
||||
}
|
||||
check 14 "Port ${FEDORA_GITEA_PORT:-3000} free on Fedora" check_port_fedora
|
||||
if ! check_port_fedora 2>/dev/null; then
|
||||
log_error " → Port ${FEDORA_GITEA_PORT:-3000} already in use on Fedora."
|
||||
# ---------------------------------------------------------------------------
|
||||
# Check 14: Port free on Fedora
|
||||
# ---------------------------------------------------------------------------
|
||||
check_port_fedora() {
|
||||
local port="${FEDORA_GITEA_PORT:-3000}"
|
||||
! ssh_exec FEDORA "ss -tlnp | grep -q ':${port} '" 2>/dev/null
|
||||
}
|
||||
check 14 "Port ${FEDORA_GITEA_PORT:-3000} free on Fedora" check_port_fedora
|
||||
if ! check_port_fedora 2>/dev/null; then
|
||||
log_error " → Port ${FEDORA_GITEA_PORT:-3000} already in use on Fedora."
|
||||
fi
|
||||
fi
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user