#!/bin/sh
set -e

# Create plugin directories with correct ownership
echo "Initializing plugin directories..."
mkdir -p /plugins /plugins-frontend /plugins-mcp
chown -R app:app /plugins /plugins-frontend /plugins-mcp
chmod -R 755 /plugins /plugins-frontend /plugins-mcp

echo "Starting API as app user..."
exec su-exec app:app /app/api "$@"
