#!/bin/bash if [[ (! -z "${NGINX_DAEMON_USER}" ) && ( "${NGINX_DAEMON_USER}" != "root" ) ]]; then useradd -r -s /bin/false $NGINX_DAEMON_USER if [[ ! -z "${NGINX_DAEMON_USER_UID}" ]]; then usermod -u $NGINX_DAEMON_USER_UID $NGINX_DAEMON_USER fi if [[ ! -z "${NGINX_DAEMON_USER_GID}" ]]; then groupmod -g $NGINX_DAEMON_USER_GID $NGINX_DAEMON_USER fi fi cp /etc/nginx/nginx.conf /etc/nginx/nginx_tmp.conf sed -i "s/user .*;//" /etc/nginx/nginx_tmp.conf echo "Chowning Data" if [[ ! -z "${NGINX_DAEMON_USER}" ]]; then chown -R $(id -u ${NGINX_DAEMON_USER}):$(id -g ${NGINX_DAEMON_USER}) /usr/share/nginx/html chown -R $(id -u ${NGINX_DAEMON_USER}):$(id -g ${NGINX_DAEMON_USER}) /etc/nginx/nginx.conf chown -R $(id -u ${NGINX_DAEMON_USER}):$(id -g ${NGINX_DAEMON_USER}) /var/log/nginx sed -i "1s/^/user ${NGINX_DAEMON_USER};\n/" /etc/nginx/nginx_tmp.conf else chown -R $(id -u):$(id -g) /usr/share/nginx/html chown -R $(id -u):$(id -g) /etc/nginx/nginx.conf chown -R $(id -u):$(id -g) /var/log/nginx sed -i "1s/^/user nginx;\n/" /etc/nginx/nginx_tmp.conf fi "$@" -c "/etc/nginx/nginx_tmp.conf" -g "daemon off;"