From 3aa23d47a234b0f923f96817830c9cfb4357ad46 Mon Sep 17 00:00:00 2001 From: Alexey Pustovalov Date: Thu, 28 May 2020 17:16:06 +0300 Subject: [PATCH] Allow to run Nginx based images under root user --- web-nginx-mysql/alpine/docker-entrypoint.sh | 7 +++++++ web-nginx-mysql/centos/docker-entrypoint.sh | 7 +++++++ web-nginx-mysql/ubuntu/docker-entrypoint.sh | 7 +++++++ web-nginx-pgsql/alpine/docker-entrypoint.sh | 7 +++++++ web-nginx-pgsql/centos/docker-entrypoint.sh | 7 +++++++ web-nginx-pgsql/ubuntu/docker-entrypoint.sh | 7 +++++++ 6 files changed, 42 insertions(+) diff --git a/web-nginx-mysql/alpine/docker-entrypoint.sh b/web-nginx-mysql/alpine/docker-entrypoint.sh index 87a1548df..c0b160528 100755 --- a/web-nginx-mysql/alpine/docker-entrypoint.sh +++ b/web-nginx-mysql/alpine/docker-entrypoint.sh @@ -236,6 +236,13 @@ prepare_zbx_web_config() { update_config_var "$PHP_CONFIG_FILE" "php_value[max_input_time]" "${ZBX_MAXINPUTTIME:-"300"}" update_config_var "$PHP_CONFIG_FILE" "php_value[date.timezone]" "${PHP_TZ}" + if [ "$(id -u)" == '0' ]; then + echo "user = zabbix" >> "$PHP_CONFIG_FILE" + echo "group = zabbix" >> "$PHP_CONFIG_FILE" + echo "listen.owner = nginx" >> "$PHP_CONFIG_FILE" + echo "listen.group = nginx" >> "$PHP_CONFIG_FILE" + fi + # Escaping characters in parameter value server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") diff --git a/web-nginx-mysql/centos/docker-entrypoint.sh b/web-nginx-mysql/centos/docker-entrypoint.sh index f1e5905de..bf6e88ad2 100755 --- a/web-nginx-mysql/centos/docker-entrypoint.sh +++ b/web-nginx-mysql/centos/docker-entrypoint.sh @@ -236,6 +236,13 @@ prepare_zbx_web_config() { update_config_var "$PHP_CONFIG_FILE" "php_value[max_input_time]" "${ZBX_MAXINPUTTIME:-"300"}" update_config_var "$PHP_CONFIG_FILE" "php_value[date.timezone]" "${PHP_TZ}" + if [ "$(id -u)" == '0' ]; then + echo "user = zabbix" >> "$PHP_CONFIG_FILE" + echo "group = zabbix" >> "$PHP_CONFIG_FILE" + echo "listen.owner = nginx" >> "$PHP_CONFIG_FILE" + echo "listen.group = nginx" >> "$PHP_CONFIG_FILE" + fi + # Escaping characters in parameter value server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") diff --git a/web-nginx-mysql/ubuntu/docker-entrypoint.sh b/web-nginx-mysql/ubuntu/docker-entrypoint.sh index c2857af4b..962a383cc 100755 --- a/web-nginx-mysql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-mysql/ubuntu/docker-entrypoint.sh @@ -236,6 +236,13 @@ prepare_zbx_web_config() { update_config_var "$PHP_CONFIG_FILE" "php_value[max_input_time]" "${ZBX_MAXINPUTTIME:-"300"}" update_config_var "$PHP_CONFIG_FILE" "php_value[date.timezone]" "${PHP_TZ}" + if [ "$(id -u)" == '0' ]; then + echo "user = zabbix" >> "$PHP_CONFIG_FILE" + echo "group = zabbix" >> "$PHP_CONFIG_FILE" + echo "listen.owner = nginx" >> "$PHP_CONFIG_FILE" + echo "listen.group = nginx" >> "$PHP_CONFIG_FILE" + fi + # Escaping characters in parameter value server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") diff --git a/web-nginx-pgsql/alpine/docker-entrypoint.sh b/web-nginx-pgsql/alpine/docker-entrypoint.sh index 162ed3f1d..9a47d4f85 100755 --- a/web-nginx-pgsql/alpine/docker-entrypoint.sh +++ b/web-nginx-pgsql/alpine/docker-entrypoint.sh @@ -236,6 +236,13 @@ prepare_zbx_web_config() { update_config_var "$PHP_CONFIG_FILE" "php_value[max_input_time]" "${ZBX_MAXINPUTTIME:-"300"}" update_config_var "$PHP_CONFIG_FILE" "php_value[date.timezone]" "${PHP_TZ}" + if [ "$(id -u)" == '0' ]; then + echo "user = zabbix" >> "$PHP_CONFIG_FILE" + echo "group = zabbix" >> "$PHP_CONFIG_FILE" + echo "listen.owner = nginx" >> "$PHP_CONFIG_FILE" + echo "listen.group = nginx" >> "$PHP_CONFIG_FILE" + fi + # Escaping characters in parameter value server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") diff --git a/web-nginx-pgsql/centos/docker-entrypoint.sh b/web-nginx-pgsql/centos/docker-entrypoint.sh index 326ce40d8..67654bfbc 100755 --- a/web-nginx-pgsql/centos/docker-entrypoint.sh +++ b/web-nginx-pgsql/centos/docker-entrypoint.sh @@ -236,6 +236,13 @@ prepare_zbx_web_config() { update_config_var "$PHP_CONFIG_FILE" "php_value[max_input_time]" "${ZBX_MAXINPUTTIME:-"300"}" update_config_var "$PHP_CONFIG_FILE" "php_value[date.timezone]" "${PHP_TZ}" + if [ "$(id -u)" == '0' ]; then + echo "user = zabbix" >> "$PHP_CONFIG_FILE" + echo "group = zabbix" >> "$PHP_CONFIG_FILE" + echo "listen.owner = nginx" >> "$PHP_CONFIG_FILE" + echo "listen.group = nginx" >> "$PHP_CONFIG_FILE" + fi + # Escaping characters in parameter value server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}") diff --git a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh index 5730f2dd5..58c2597b2 100755 --- a/web-nginx-pgsql/ubuntu/docker-entrypoint.sh +++ b/web-nginx-pgsql/ubuntu/docker-entrypoint.sh @@ -236,6 +236,13 @@ prepare_zbx_web_config() { update_config_var "$PHP_CONFIG_FILE" "php_value[max_input_time]" "${ZBX_MAXINPUTTIME:-"300"}" update_config_var "$PHP_CONFIG_FILE" "php_value[date.timezone]" "${PHP_TZ}" + if [ "$(id -u)" == '0' ]; then + echo "user = zabbix" >> "$PHP_CONFIG_FILE" + echo "group = zabbix" >> "$PHP_CONFIG_FILE" + echo "listen.owner = nginx" >> "$PHP_CONFIG_FILE" + echo "listen.group = nginx" >> "$PHP_CONFIG_FILE" + fi + # Escaping characters in parameter value server_name=$(escape_spec_char "${ZBX_SERVER_NAME}") server_user=$(escape_spec_char "${DB_SERVER_ZBX_USER}")