head-vps/dns/apply.sh

12 lines
561 B
Shell
Executable file

#!/bin/sh
# One run of the DNS workflow on the VPS: decrypt the token and the state passphrase with the host's
# age key, plan, apply. The (encrypted) state lives in the dns_state volume, never in git.
# `apply.sh plan` only plans.
set -eu
FNOX_AGE_KEY="$(cat /run/secrets/age_key)"
export FNOX_AGE_KEY
fnox exec -- tofu init -input=false -reconfigure -plugin-dir=/dns/providers -backend-config=path=/state/terraform.tfstate
if [ "${1:-apply}" = plan ]; then
exec fnox exec -- tofu plan -input=false
fi
exec fnox exec -- tofu apply -input=false -auto-approve