diff --git a/scripts/setup/officer-setup.sh b/scripts/setup/officer-setup.sh index 7b63f30f..a6148ab3 100755 --- a/scripts/setup/officer-setup.sh +++ b/scripts/setup/officer-setup.sh @@ -141,6 +141,26 @@ info "Account: ${USERNAME} (home ${USER_HOME})" info "Officer: ${OFFICER_ROOT}" [[ -n "$MACHINE_ROLE" ]] && info "Role: ${MACHINE_ROLE}" +# ── recover what earlier runs already decided ── +# +# A skipped section leaves its variables unset, and later sections read them. On +# a resume that is every section before the one it stopped at, so Build announced +# "PUBLIC_URL " on a machine whose +# .env had been written twenty minutes earlier. +# +# Read back here, once, from the file that already holds the answers, rather than +# per-section — three variables cross a section boundary (ENV_PORT and +# ENV_PUBLIC_URL from Environment, POSTGRES_URL from Database) and the next one +# added would have to remember to do this again. +# +# Only fills what is EMPTY, so a variable passed in on the command line still +# wins, and a section that runs for real still overwrites it with its own answer. +if [[ -f "$(env_file)" ]]; then + ENV_PORT="${ENV_PORT:-$(env_get PORT)}" + ENV_PUBLIC_URL="${ENV_PUBLIC_URL:-$(env_get PUBLIC_URL)}" + POSTGRES_URL="${POSTGRES_URL:-$(env_get POSTGRES_URL)}" +fi + # ── is the machine actually ready ── # # Checked and reported together. Finding out about a missing bun three sections @@ -640,10 +660,6 @@ if ! skip; then echo " To change it later: bun gen:index https://your.new.url" echo "" - if [[ -z "${ENV_PUBLIC_URL:-}" ]]; then - ENV_PUBLIC_URL="$(env_get PUBLIC_URL)" - fi - if [[ -z "$ENV_PUBLIC_URL" ]]; then warn "PUBLIC_URL is not in $(env_file) — run the Environment section, then this one" SUMMARY+=("Build: SKIPPED — no PUBLIC_URL")