#!/bin/sh
# Reject a production env file that is still on the placeholders or on localhost.
set -eu
file=${1:-deployment/production/example.env}
required="PUBLIC_HOSTNAME RELAY_HOST PUBLIC_IP DATA_DIR BACKUP_DIR"
for name in $required; do
    value=$(sed -n "s/^${name}=//p" "$file" | head -n 1)
    if [ -z "$value" ]; then
        echo "missing $name" >&2
        exit 1
    fi
    case "$value" in
        *example.com*|203.0.113.10|127.0.0.1|*localhost*)
            echo "$name is still a placeholder: $value" >&2
            exit 1
            ;;
    esac
done
echo "production env looks ready to review"
