#!/usr/bin/sh
set -eu

CONFIG=${YA_CONFIG:-/etc/yabo/config}
# shellcheck source=/dev/null
. "$CONFIG"

# Adopt the content root so the unprivileged yabo workers can write and NFS
# clients squashed to yabo can delete. Idempotent: the find matches nothing
# once ownership has converged.
install -d -o yabo -g yabo "$YA_ROOT"
# -h/-xdev keep this privileged chown from following a stray symlink to a
# target outside the tree, or crossing into another mounted filesystem.
find "$YA_ROOT" -xdev ! -user yabo -exec chown -h yabo:yabo {} +
