#!/bin/sh
set -e

# Create cache directories with correct ownership
# This runs as root before we switch to nodejs user
mkdir -p /app/uploads/youtube-cache /app/uploads/soundcloud-cache
chown -R nodejs:nodejs /app/uploads

# Drop privileges and run the actual command
exec su-exec nodejs "$@"
