# Keep the copy of its Authelia client current (apps installed before
# copies were kept get one); Authelia's start restores clients from these
IDP=/federated/apps/authelia/data/config/idproviders.yml
COPY=/federated/apps/{{NAME}}/.{{NAME}}.oidc-client.yml
if grep -qx '      ### coreapp-{{NAME}} begin' "$IDP"; then
  sed -n '/^      ### coreapp-{{NAME}} begin$/,/^      ### coreapp-{{NAME}} end$/p' "$IDP" > "$COPY"
  chmod 600 "$COPY"
fi
unset IDP COPY
