|
3 | 3 |
|
4 | 4 | set -e |
5 | 5 |
|
| 6 | +entrypoint_log() { |
| 7 | + if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then |
| 8 | + echo "$@" |
| 9 | + fi |
| 10 | +} |
| 11 | + |
6 | 12 | ME=$(basename $0) |
7 | 13 | DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf" |
8 | 14 |
|
9 | 15 | # check if we have ipv6 available |
10 | 16 | if [ ! -f "/proc/net/if_inet6" ]; then |
11 | | - echo >&3 "$ME: info: ipv6 not available" |
| 17 | + entrypoint_log "$ME: info: ipv6 not available" |
12 | 18 | exit 0 |
13 | 19 | fi |
14 | 20 |
|
15 | 21 | if [ ! -f "/$DEFAULT_CONF_FILE" ]; then |
16 | | - echo >&3 "$ME: info: /$DEFAULT_CONF_FILE is not a file or does not exist" |
| 22 | + entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE is not a file or does not exist" |
17 | 23 | exit 0 |
18 | 24 | fi |
19 | 25 |
|
20 | 26 | # check if the file can be modified, e.g. not on a r/o filesystem |
21 | | -touch /$DEFAULT_CONF_FILE 2>/dev/null || { echo >&3 "$ME: info: can not modify /$DEFAULT_CONF_FILE (read-only file system?)"; exit 0; } |
| 27 | +touch /$DEFAULT_CONF_FILE 2>/dev/null || { entrypoint_log "$ME: info: can not modify /$DEFAULT_CONF_FILE (read-only file system?)"; exit 0; } |
22 | 28 |
|
23 | 29 | # check if the file is already modified, e.g. on a container restart |
24 | | -grep -q "listen \[::]\:8080;" /$DEFAULT_CONF_FILE && { echo >&3 "$ME: info: IPv6 listen already enabled"; exit 0; } |
| 30 | +grep -q "listen \[::]\:8080;" /$DEFAULT_CONF_FILE && { entrypoint_log "$ME: info: IPv6 listen already enabled"; exit 0; } |
25 | 31 |
|
26 | 32 | if [ -f "/etc/os-release" ]; then |
27 | 33 | . /etc/os-release |
28 | 34 | else |
29 | | - echo >&3 "$ME: info: can not guess the operating system" |
| 35 | + entrypoint_log "$ME: info: can not guess the operating system" |
30 | 36 | exit 0 |
31 | 37 | fi |
32 | 38 |
|
33 | | -echo >&3 "$ME: info: Getting the checksum of /$DEFAULT_CONF_FILE" |
| 39 | +entrypoint_log "$ME: info: Getting the checksum of /$DEFAULT_CONF_FILE" |
34 | 40 |
|
35 | 41 | case "$ID" in |
36 | 42 | "debian") |
37 | 43 | CHECKSUM=$(dpkg-query --show --showformat='${Conffiles}\n' nginx | grep $DEFAULT_CONF_FILE | cut -d' ' -f 3) |
38 | 44 | echo "$CHECKSUM /$DEFAULT_CONF_FILE" | md5sum -c - >/dev/null 2>&1 || { |
39 | | - echo >&3 "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version" |
| 45 | + entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version" |
40 | 46 | exit 0 |
41 | 47 | } |
42 | 48 | ;; |
43 | 49 | "alpine") |
44 | 50 | CHECKSUM=$(apk manifest nginx 2>/dev/null| grep $DEFAULT_CONF_FILE | cut -d' ' -f 1 | cut -d ':' -f 2) |
45 | 51 | echo "$CHECKSUM /$DEFAULT_CONF_FILE" | sha1sum -c - >/dev/null 2>&1 || { |
46 | | - echo >&3 "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version" |
| 52 | + entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version" |
47 | 53 | exit 0 |
48 | 54 | } |
49 | 55 | ;; |
50 | 56 | *) |
51 | | - echo >&3 "$ME: info: Unsupported distribution" |
| 57 | + entrypoint_log "$ME: info: Unsupported distribution" |
52 | 58 | exit 0 |
53 | 59 | ;; |
54 | 60 | esac |
55 | 61 |
|
56 | 62 | # enable ipv6 on default.conf listen sockets |
57 | 63 | sed -i -E 's,listen 8080;,listen 8080;\n listen [::]:8080;,' /$DEFAULT_CONF_FILE |
58 | 64 |
|
59 | | -echo >&3 "$ME: info: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE" |
| 65 | +entrypoint_log "$ME: info: Enabled listen on IPv6 in /$DEFAULT_CONF_FILE" |
60 | 66 |
|
61 | 67 | exit 0 |
0 commit comments