#!/bin/sh -e

key_path="$( cat "$__object/parameter/key-path" )"

if echo "$key_path" | grep -Fq '%s'
then
    # shellcheck disable=SC2059
    key_path="$( printf "$key_path" "$__object_id" )"
fi

cert_path="$( cat "$__object/parameter/cert-path" )"

if echo "$cert_path" | grep -Fq '%s'
then
    # shellcheck disable=SC2059
    cert_path="$( printf "$cert_path" "$__object_id" )"
fi

if [ ! -f "$key_path" ] || [ ! -f "$cert_path" ]
then
    echo 'absent'
else
    echo 'present'
fi
