#!/bin/bash set -e # Ensure the logs directory has the correct permissions echo "Changing permissions on logs directory" #chown -R appuser:appuser /app/logs chmod -R 777 /app/logs # Wait for the database to be ready until pg_isready -h $DB_HOST -p $DB_PORT; do echo "Postgres is unavailable - sleeping" sleep 2 done # Switch to appuser and execute the command passed to the script exec su appuser -c "$@"