#!/bin/sh
# Puppet's exec node_terminus invokes external_nodes with a certname and no
# environment, so the encapi URL cannot be inherited; source it here instead.
set -eu

for conf in /etc/encapic/encapic.conf /etc/encapi/encapic.conf; do
	if [ -r "$conf" ]; then
		. "$conf"
	fi
done
if [ -n "${ENCAPI_URL:-}" ]; then
	export ENCAPI_URL
fi

exec /usr/bin/encapic "$@"
