#!/bin/sh

# FIXME: this code is duplicated from the manifest -> let's share it somehow.

os="$(cat "${__global:?}"/explorer/os)"
case "$os" in
	alpine|ubuntu|debian)
		default_confdir=/etc/ssl/uacme
	;;
	*)
		echo "__uacme_obtain currently has no implementation for $os. Aborting." >&2;
		exit 1;
	;;
esac

confdir="${default_confdir:?}"
if [ -f "${__object:?}/parameter/confdir" ];
then
	confdir="$(cat "${__object:?}/parameter/confdir")"
fi

# Run renew script 'by hand' for intial issue - renews will be handled by the
# cronjob.
echo "$confdir/${__object_id:?}/renew.sh"
