#!/bin/bash

# read the default key from /pg/conf/pgsodium.key
# fallback to pg_cluster

# https://github.com/michelp/pgsodium?tab=readme-ov-file#usage

PGSODIUM_KEY_PATH="/pg/conf/pgsodium.key"

if [[ ! -f $PGSODIUM_KEY_PATH ]]; then
  echo "{{ pgsodium_key | default(pg_cluster|hash('sha256')) }}"
  exit 1
fi

cat $PGSODIUM_KEY_PATH