feat: extract .env validators to common.sh and add validate_env()

Move 10 validation functions from configure_env.sh to lib/common.sh as
shared utilities. Define variable-to-validator mapping using parallel
arrays (bash 3.2 compatible). validate_env() checks all ~50 .env
variables against their expected format and reports all failures at once.

Wired into preflight.sh (Check 6b) and bitwarden_to_env.sh (post-restore).
configure_env.sh now sources validators from common.sh instead of
defining its own copies.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
S
2026-02-28 22:08:01 -05:00
parent 743f1281e6
commit 0e0aeda658
7 changed files with 192 additions and 45 deletions

View File

@@ -36,11 +36,14 @@ backup/ # Backup and restore scripts
## Key Commands
- `setup/configure_env.sh` — Interactive .env setup wizard
- `setup/cleanup.sh` — Reverse everything setup scripts installed (reads .manifests/)
- `preflight.sh` — Validate everything before running phases
- `preflight.sh` — Validate everything before running phases (includes .env format validation)
- `run_all.sh` — Execute all phases sequentially
- `teardown_all.sh` — Reverse teardown (add `--cleanup` to also uninstall prerequisites)
- `manage_runner.sh add|remove|list` — Dynamic runner management
## .env Validation
`validate_env()` in `lib/common.sh` checks all ~50 .env variables against their expected format (IP, port, email, path, URL, bool, integer, password, ssl_mode). Uses parallel arrays for the variable-to-validator mapping (bash 3.2 compatible). Called by `preflight.sh` and `bitwarden_to_env.sh`. `configure_env.sh` uses the same individual validators interactively.
## Version Checking
Setup scripts and preflight validate minimum versions for all tools:
- Local: jq>=1.6, curl>=7.70, git>=2.30, shellcheck>=0.8, gh>=2.0