#!/command/with-contenv bash
# shellcheck shell=bash

LOG_DIR=$1

if [ -z "$LOG_DIR" ]; then
    echo "Usage: $0 <log-dir>"
    exit 1
fi

CMD=(s6-log -b -- ${S6_LOGGING_SCRIPT:-n20 s1000000 T} "$LOG_DIR")

if [ "$(id -u)" = "0" ]; then
    exec /command/s6-envuidgid nobody /command/s6-applyuidgid -U -- "${CMD[@]}"
else
    exec "${CMD[@]}"
fi
