Skip to content

Commit a86ccdc

Browse files
alexandresalomethresheek
authored andcommitted
Add NGINX_ENTRYPOINT_QUIET_LOGS environment variable
1 parent d8cbd8e commit a86ccdc

24 files changed

+144
-96
lines changed

mainline/alpine-perl/10-listen-on-ipv6-by-default.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
1818
fi
1919

2020
# check if the file can be modified, e.g. not on a r/o filesystem
21-
touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo "$ME: Can not modify /$DEFAULT_CONF_FILE (read-only file system?), exiting"; exit 0; }
21+
touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo >&3 "$ME: Can not modify /$DEFAULT_CONF_FILE (read-only file system?), exiting"; exit 0; }
2222

2323
# check if the file is already modified, e.g. on a container restart
24-
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
24+
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo >&3 "$ME: IPv6 listen already enabled, exiting"; exit 0; }
2525

2626
if [ -f "/etc/os-release" ]; then
2727
. /etc/os-release
@@ -30,7 +30,7 @@ else
3030
exit 0
3131
fi
3232

33-
echo "$ME: Getting the checksum of /$DEFAULT_CONF_FILE"
33+
echo >&3 "$ME: Getting the checksum of /$DEFAULT_CONF_FILE"
3434

3535
case "$ID" in
3636
"debian")
@@ -56,6 +56,6 @@ esac
5656
# enable ipv6 on default.conf listen sockets
5757
sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' /$DEFAULT_CONF_FILE
5858

59-
echo "$ME: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE"
59+
echo >&3 "$ME: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE"
6060

6161
exit 0

mainline/alpine-perl/20-envsubst-on-templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ auto_envsubst() {
2222
subdir=$(dirname "$relative_path")
2323
# create a subdirectory where the template file exists
2424
mkdir -p "$output_dir/$subdir"
25-
echo "$ME: Running envsubst on $template to $output_path"
25+
echo >&3 "$ME: Running envsubst on $template to $output_path"
2626
envsubst "$defined_envs" < "$template" > "$output_path"
2727
done
2828
}

mainline/alpine-perl/docker-entrypoint.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,35 @@
33

44
set -e
55

6+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
7+
exec 3>&1
8+
else
9+
exec 3>/dev/null
10+
fi
11+
612
if [ "$1" = "nginx" -o "$1" = "nginx-debug" ]; then
713
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
8-
echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
14+
echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
915

10-
echo "$0: Looking for shell scripts in /docker-entrypoint.d/"
16+
echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/"
1117
find "/docker-entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do
1218
case "$f" in
1319
*.sh)
1420
if [ -x "$f" ]; then
15-
echo "$0: Launching $f";
21+
echo >&3 "$0: Launching $f";
1622
"$f"
1723
else
1824
# warn on shell scripts without exec bit
19-
echo "$0: Ignoring $f, not executable";
25+
echo >&3 "$0: Ignoring $f, not executable";
2026
fi
2127
;;
22-
*) echo "$0: Ignoring $f";;
28+
*) echo >&3 "$0: Ignoring $f";;
2329
esac
2430
done
2531

26-
echo "$0: Configuration complete; ready for start up"
32+
echo >&3 "$0: Configuration complete; ready for start up"
2733
else
28-
echo "$0: No files found in /docker-entrypoint.d/, skipping configuration"
34+
echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration"
2935
fi
3036
fi
3137

mainline/alpine/10-listen-on-ipv6-by-default.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
1818
fi
1919

2020
# check if the file can be modified, e.g. not on a r/o filesystem
21-
touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo "$ME: Can not modify /$DEFAULT_CONF_FILE (read-only file system?), exiting"; exit 0; }
21+
touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo >&3 "$ME: Can not modify /$DEFAULT_CONF_FILE (read-only file system?), exiting"; exit 0; }
2222

2323
# check if the file is already modified, e.g. on a container restart
24-
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
24+
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo >&3 "$ME: IPv6 listen already enabled, exiting"; exit 0; }
2525

2626
if [ -f "/etc/os-release" ]; then
2727
. /etc/os-release
@@ -30,7 +30,7 @@ else
3030
exit 0
3131
fi
3232

33-
echo "$ME: Getting the checksum of /$DEFAULT_CONF_FILE"
33+
echo >&3 "$ME: Getting the checksum of /$DEFAULT_CONF_FILE"
3434

3535
case "$ID" in
3636
"debian")
@@ -56,6 +56,6 @@ esac
5656
# enable ipv6 on default.conf listen sockets
5757
sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' /$DEFAULT_CONF_FILE
5858

59-
echo "$ME: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE"
59+
echo >&3 "$ME: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE"
6060

6161
exit 0

mainline/alpine/20-envsubst-on-templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ auto_envsubst() {
2222
subdir=$(dirname "$relative_path")
2323
# create a subdirectory where the template file exists
2424
mkdir -p "$output_dir/$subdir"
25-
echo "$ME: Running envsubst on $template to $output_path"
25+
echo >&3 "$ME: Running envsubst on $template to $output_path"
2626
envsubst "$defined_envs" < "$template" > "$output_path"
2727
done
2828
}

mainline/alpine/docker-entrypoint.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,35 @@
33

44
set -e
55

6+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
7+
exec 3>&1
8+
else
9+
exec 3>/dev/null
10+
fi
11+
612
if [ "$1" = "nginx" -o "$1" = "nginx-debug" ]; then
713
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
8-
echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
14+
echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
915

10-
echo "$0: Looking for shell scripts in /docker-entrypoint.d/"
16+
echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/"
1117
find "/docker-entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do
1218
case "$f" in
1319
*.sh)
1420
if [ -x "$f" ]; then
15-
echo "$0: Launching $f";
21+
echo >&3 "$0: Launching $f";
1622
"$f"
1723
else
1824
# warn on shell scripts without exec bit
19-
echo "$0: Ignoring $f, not executable";
25+
echo >&3 "$0: Ignoring $f, not executable";
2026
fi
2127
;;
22-
*) echo "$0: Ignoring $f";;
28+
*) echo >&3 "$0: Ignoring $f";;
2329
esac
2430
done
2531

26-
echo "$0: Configuration complete; ready for start up"
32+
echo >&3 "$0: Configuration complete; ready for start up"
2733
else
28-
echo "$0: No files found in /docker-entrypoint.d/, skipping configuration"
34+
echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration"
2935
fi
3036
fi
3137

mainline/buster-perl/10-listen-on-ipv6-by-default.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
1818
fi
1919

2020
# check if the file can be modified, e.g. not on a r/o filesystem
21-
touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo "$ME: Can not modify /$DEFAULT_CONF_FILE (read-only file system?), exiting"; exit 0; }
21+
touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo >&3 "$ME: Can not modify /$DEFAULT_CONF_FILE (read-only file system?), exiting"; exit 0; }
2222

2323
# check if the file is already modified, e.g. on a container restart
24-
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
24+
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo >&3 "$ME: IPv6 listen already enabled, exiting"; exit 0; }
2525

2626
if [ -f "/etc/os-release" ]; then
2727
. /etc/os-release
@@ -30,7 +30,7 @@ else
3030
exit 0
3131
fi
3232

33-
echo "$ME: Getting the checksum of /$DEFAULT_CONF_FILE"
33+
echo >&3 "$ME: Getting the checksum of /$DEFAULT_CONF_FILE"
3434

3535
case "$ID" in
3636
"debian")
@@ -56,6 +56,6 @@ esac
5656
# enable ipv6 on default.conf listen sockets
5757
sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' /$DEFAULT_CONF_FILE
5858

59-
echo "$ME: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE"
59+
echo >&3 "$ME: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE"
6060

6161
exit 0

mainline/buster-perl/20-envsubst-on-templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ auto_envsubst() {
2222
subdir=$(dirname "$relative_path")
2323
# create a subdirectory where the template file exists
2424
mkdir -p "$output_dir/$subdir"
25-
echo "$ME: Running envsubst on $template to $output_path"
25+
echo >&3 "$ME: Running envsubst on $template to $output_path"
2626
envsubst "$defined_envs" < "$template" > "$output_path"
2727
done
2828
}

mainline/buster-perl/docker-entrypoint.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,35 @@
33

44
set -e
55

6+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
7+
exec 3>&1
8+
else
9+
exec 3>/dev/null
10+
fi
11+
612
if [ "$1" = "nginx" -o "$1" = "nginx-debug" ]; then
713
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
8-
echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
14+
echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
915

10-
echo "$0: Looking for shell scripts in /docker-entrypoint.d/"
16+
echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/"
1117
find "/docker-entrypoint.d/" -follow -type f -print | sort -n | while read -r f; do
1218
case "$f" in
1319
*.sh)
1420
if [ -x "$f" ]; then
15-
echo "$0: Launching $f";
21+
echo >&3 "$0: Launching $f";
1622
"$f"
1723
else
1824
# warn on shell scripts without exec bit
19-
echo "$0: Ignoring $f, not executable";
25+
echo >&3 "$0: Ignoring $f, not executable";
2026
fi
2127
;;
22-
*) echo "$0: Ignoring $f";;
28+
*) echo >&3 "$0: Ignoring $f";;
2329
esac
2430
done
2531

26-
echo "$0: Configuration complete; ready for start up"
32+
echo >&3 "$0: Configuration complete; ready for start up"
2733
else
28-
echo "$0: No files found in /docker-entrypoint.d/, skipping configuration"
34+
echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration"
2935
fi
3036
fi
3137

mainline/buster/10-listen-on-ipv6-by-default.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
1818
fi
1919

2020
# check if the file can be modified, e.g. not on a r/o filesystem
21-
touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo "$ME: Can not modify /$DEFAULT_CONF_FILE (read-only file system?), exiting"; exit 0; }
21+
touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo >&3 "$ME: Can not modify /$DEFAULT_CONF_FILE (read-only file system?), exiting"; exit 0; }
2222

2323
# check if the file is already modified, e.g. on a container restart
24-
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
24+
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo >&3 "$ME: IPv6 listen already enabled, exiting"; exit 0; }
2525

2626
if [ -f "/etc/os-release" ]; then
2727
. /etc/os-release
@@ -30,7 +30,7 @@ else
3030
exit 0
3131
fi
3232

33-
echo "$ME: Getting the checksum of /$DEFAULT_CONF_FILE"
33+
echo >&3 "$ME: Getting the checksum of /$DEFAULT_CONF_FILE"
3434

3535
case "$ID" in
3636
"debian")
@@ -56,6 +56,6 @@ esac
5656
# enable ipv6 on default.conf listen sockets
5757
sed -i -E 's,listen 80;,listen 80;\n listen [::]:80;,' /$DEFAULT_CONF_FILE
5858

59-
echo "$ME: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE"
59+
echo >&3 "$ME: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE"
6060

6161
exit 0

0 commit comments

Comments
 (0)