#!/bin/bash set -e # Set www-data user uid and group in order to have correct permissions if [ -n "$USER_UID" ]; then # only if the uid is not already correct if [ "$USER_UID" != "$(id -u www-data)" ]; then echo "change uid $USER_UID on www-data" usermod -u "$USER_UID" www-data || true; fi fi if [ -n "$USER_GROUP" ]; then # only if the Guid is not already correct if [ "$USER_GROUP" != "$(id -g www-data)" ]; then echo "change group $USER_GROUP on www-data" if getent group "$USER_GROUP" ; then usermod -G "$USER_GROUP" www-data || true; else groupmod -g "$USER_GROUP" www-data || true; fi fi fi . /usr/local/bin/init.sh exec php-fpm --nodaemonize