#!/bin/sh
set -e

DATA_DIR="/app/data"
UPLOADS_DIR="/app/uploads"

mkdir -p "$DATA_DIR" "$UPLOADS_DIR"

if [ "$(id -u)" = "0" ]; then
    chown -R appuser:appgroup "$DATA_DIR" "$UPLOADS_DIR"
    exec su-exec appuser "$@"
else
    exec "$@"
fi
