#!/bin/sh
# Deploy event-currency GOA exchange (regional-currency flow + systemd).
# Prerequisites on koopa:
#   1) ./run-container-koopa.sh   # systemd container, port 9011
#   2) this script
# Inventory: ansible_connection=podman
set -eu
cd "$(dirname "$0")"
export PATH="${HOME}/venv-ansible/bin:${PATH}"
export ANSIBLE_HOST_KEY_CHECKING=False
if [ ! -f vault_pass.txt ]; then
  echo unused > vault_pass.txt
fi

# Refuse obvious non-systemd targets early
if ! podman exec taler-hacktivism-exchange-ansible cat /proc/1/comm 2>/dev/null | grep -qx systemd; then
  echo "error: container PID1 is not systemd. Run ./run-container-koopa.sh first." >&2
  exit 1
fi

exec ansible-playbook -v \
  --limit taler-hacktivism-exchange-ansible \
  -e @inventories/host_vars/taler-hacktivism-exchange-ansible/public.yml \
  -e @inventories/host_vars/taler-hacktivism-exchange-ansible/secrets.yml \
  playbooks/setup-hacktivism-goa.yml
