#!/bin/sh -eu
url=$(grep ^location /var/snap/candid/current/config.yaml | cut -d: -f2- | sed "s/[ '\"]//g" || true)

if [ -z "${CANDID_URL:-}" ] && [ -n "${url}" ]; then
    export CANDID_URL=${url}
fi

exec candid "$@"
