Skip to content

Commit bb234dd

Browse files
committed
Bug fix, linter fixes, minor formatting fixes
1 parent a4d9a5c commit bb234dd

36 files changed

+497
-485
lines changed

Dockerfile-alpine-perl.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ RUN set -x \
6666
# remove checksum deps
6767
&& apk del --no-network .checksum-deps \
6868
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
69-
&& if [ -n "$tempDir" ]; then rm -rf "$tempDir"; fi \
70-
&& if [ -n "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
71-
&& if [ -n "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi
69+
&& if [ -f "$tempDir" ]; then rm -rf "$tempDir"; fi \
70+
&& if [ -f "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
71+
&& if [ -f "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi

Dockerfile-alpine-slim.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ RUN set -x \
7373
# remove checksum deps
7474
&& apk del --no-network .checksum-deps \
7575
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
76-
&& if [ -n "$tempDir" ]; then rm -rf "$tempDir"; fi \
77-
&& if [ -n "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
78-
&& if [ -n "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi \
76+
&& if [ -f "$tempDir" ]; then rm -rf "$tempDir"; fi \
77+
&& if [ -f "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
78+
&& if [ -f "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi \
7979
# Bring in gettext so we can get `envsubst`, then throw
8080
# the rest away. To do this, we need to install `gettext`
8181
# then move `envsubst` out of the way so `gettext` can

Dockerfile-alpine.template

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ RUN set -x \
7171
# remove checksum deps
7272
&& apk del --no-network .checksum-deps \
7373
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
74-
&& if [ -n "$tempDir" ]; then rm -rf "$tempDir"; fi \
75-
&& if [ -n "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
76-
&& if [ -n "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi \
74+
&& if [ -f "$tempDir" ]; then rm -rf "$tempDir"; fi \
75+
&& if [ -f "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
76+
&& if [ -f "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi \
7777
# Bring in curl and ca-certificates to make registering on DNS SD easier
7878
&& apk add --no-cache curl ca-certificates

entrypoint/10-listen-on-ipv6-by-default.sh

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
1-
#!/bin/sh
2-
# vim:sw=4:ts=4:et
1+
#!/usr/bin/env/sh
2+
# vim:sw=2:ts=2:sts=2:et
33

44
set -e
55

66
entrypoint_log() {
7-
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
8-
echo "$@"
9-
fi
7+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
8+
echo "$@"
9+
fi
1010
}
1111

1212
ME=$(basename $0)
1313
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
1414

1515
# check if we have ipv6 available
1616
if [ ! -f "/proc/net/if_inet6" ]; then
17-
entrypoint_log "$ME: info: ipv6 not available"
18-
exit 0
17+
entrypoint_log "$ME: info: IPv6 is not available"
18+
exit 0
1919
fi
2020

2121
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
22-
entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE is not a file or does not exist"
23-
exit 0
22+
entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE is not a file or does not exist"
23+
exit 0
2424
fi
2525

2626
# check if the file can be modified, e.g. not on a r/o filesystem
27-
touch /$DEFAULT_CONF_FILE 2>/dev/null || { entrypoint_log "$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: Cannot modify /$DEFAULT_CONF_FILE (read-only file system?)"; exit 0; }
2828

2929
# check if the file is already modified, e.g. on a container restart
30-
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { entrypoint_log "$ME: info: IPv6 listen already enabled"; exit 0; }
30+
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { entrypoint_log "$ME: info: Listen on IPv6 is already enabled"; exit 0; }
3131

3232
if [ -f "/etc/os-release" ]; then
33-
. /etc/os-release
33+
. /etc/os-release
3434
else
35-
entrypoint_log "$ME: info: can not guess the operating system"
36-
exit 0
35+
entrypoint_log "$ME: info: Cannot guess the operating system"
36+
exit 0
3737
fi
3838

3939
entrypoint_log "$ME: info: Getting the checksum of /$DEFAULT_CONF_FILE"
4040

4141
case "$ID" in
42-
"debian")
43-
CHECKSUM=$(dpkg-query --show --showformat='${Conffiles}\n' nginx | grep $DEFAULT_CONF_FILE | cut -d' ' -f 3)
44-
echo "$CHECKSUM /$DEFAULT_CONF_FILE" | md5sum -c - >/dev/null 2>&1 || {
45-
entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version"
46-
exit 0
47-
}
48-
;;
49-
"alpine")
50-
CHECKSUM=$(apk manifest nginx 2>/dev/null| grep $DEFAULT_CONF_FILE | cut -d' ' -f 1 | cut -d ':' -f 2)
51-
echo "$CHECKSUM /$DEFAULT_CONF_FILE" | sha1sum -c - >/dev/null 2>&1 || {
52-
entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version"
53-
exit 0
54-
}
55-
;;
56-
*)
57-
entrypoint_log "$ME: info: Unsupported distribution"
58-
exit 0
59-
;;
42+
"debian")
43+
CHECKSUM=$(dpkg-query --show --showformat='${Conffiles}\n' nginx | grep $DEFAULT_CONF_FILE | cut -d' ' -f 3)
44+
echo "$CHECKSUM /$DEFAULT_CONF_FILE" | md5sum -c - >/dev/null 2>&1 || {
45+
entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version"
46+
exit 0
47+
}
48+
;;
49+
"alpine")
50+
CHECKSUM=$(apk manifest nginx 2>/dev/null| grep $DEFAULT_CONF_FILE | cut -d' ' -f 1 | cut -d ':' -f 2)
51+
echo "$CHECKSUM /$DEFAULT_CONF_FILE" | sha1sum -c - >/dev/null 2>&1 || {
52+
entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version"
53+
exit 0
54+
}
55+
;;
56+
*)
57+
entrypoint_log "$ME: info: Unsupported distribution"
58+
exit 0
59+
;;
6060
esac
6161

6262
# enable ipv6 on default.conf listen sockets

entrypoint/15-local-resolvers.envsh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#!/bin/sh
1+
#!/usr/bin/env/sh
22
# vim:sw=2:ts=2:sts=2:et
33

44
set -eu
55

66
LC_ALL=C
77
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
88

9-
[ "${NGINX_ENTRYPOINT_LOCAL_RESOLVERS:-}" ] || return 0
9+
[ "${NGINX_ENTRYPOINT_LOCAL_RESOLVERS:-}" ] || exit 0
1010

11-
export NGINX_LOCAL_RESOLVERS=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf)
11+
NGINX_LOCAL_RESOLVERS=$(awk 'BEGIN{ORS=" "} $1=="nameserver" {print $2}' /etc/resolv.conf)
12+
export NGINX_LOCAL_RESOLVERS

entrypoint/20-envsubst-on-templates.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
#!/bin/sh
1+
#!/usr/bin/env/sh
2+
# vim:sw=2:ts=2:sts=2:et
23

34
set -e
45

56
ME=$(basename $0)
67

78
entrypoint_log() {
8-
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
9-
echo "$@"
10-
fi
9+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
10+
echo "$@"
11+
fi
1112
}
1213

1314
add_stream_block() {
@@ -17,8 +18,8 @@ add_stream_block() {
1718
entrypoint_log "$ME: $conffile contains a stream block; include $stream_output_dir/*.conf to enable stream templates"
1819
else
1920
# check if the file can be modified, e.g. not on a r/o filesystem
20-
touch "$conffile" 2>/dev/null || { entrypoint_log "$ME: info: can not modify $conffile (read-only file system?)"; exit 0; }
21-
entrypoint_log "$ME: Appending stream block to $conffile to include $stream_output_dir/*.conf"
21+
touch "$conffile" 2>/dev/null || { entrypoint_log "$ME: ERROR: can not modify $conffile (read-only file system?)"; return 0; }
22+
entrypoint_log "$ME: info: Appending stream block to $conffile to include $stream_output_dir/*.conf"
2223
cat << END >> "$conffile"
2324
# added by "$ME" on "$(date)"
2425
stream {
@@ -35,21 +36,21 @@ auto_envsubst() {
3536
local stream_suffix="${NGINX_ENVSUBST_STREAM_TEMPLATE_SUFFIX:-.stream-template}"
3637
local stream_output_dir="${NGINX_ENVSUBST_STREAM_OUTPUT_DIR:-/etc/nginx/stream-conf.d}"
3738
local filter="${NGINX_ENVSUBST_FILTER:-}"
38-
3939
local template defined_envs relative_path output_path subdir
40-
defined_envs=$(printf '${%s} ' $(awk "END { for (name in ENVIRON) { print ( name ~ /${filter}/ ) ? name : \"\" } }" < /dev/null ))
40+
41+
defined_envs=$(printf "%s" "$(awk "END { for (name in ENVIRON) { print ( name ~ /${filter}/ ) ? name : \"\" } }" < /dev/null )")
4142
[ -d "$template_dir" ] || return 0
4243
if [ ! -w "$output_dir" ]; then
4344
entrypoint_log "$ME: ERROR: $template_dir exists, but $output_dir is not writable"
4445
return 0
4546
fi
4647
find "$template_dir" -follow -type f -name "*$suffix" -print | while read -r template; do
47-
relative_path="${template#$template_dir/}"
48-
output_path="$output_dir/${relative_path%$suffix}"
48+
relative_path="${template#"$template_dir"/}"
49+
output_path="$output_dir/${relative_path%"$suffix"}"
4950
subdir=$(dirname "$relative_path")
5051
# create a subdirectory where the template file exists
5152
mkdir -p "$output_dir/$subdir"
52-
entrypoint_log "$ME: Running envsubst on $template to $output_path"
53+
entrypoint_log "$ME: info: Running envsubst on $template to $output_path"
5354
envsubst "$defined_envs" < "$template" > "$output_path"
5455
done
5556

@@ -62,12 +63,12 @@ auto_envsubst() {
6263
fi
6364
add_stream_block
6465
find "$template_dir" -follow -type f -name "*$stream_suffix" -print | while read -r template; do
65-
relative_path="${template#$template_dir/}"
66-
output_path="$stream_output_dir/${relative_path%$stream_suffix}"
66+
relative_path="${template#"$template_dir"/}"
67+
output_path="$stream_output_dir/${relative_path%"$stream_suffix"}"
6768
subdir=$(dirname "$relative_path")
6869
# create a subdirectory where the template file exists
6970
mkdir -p "$stream_output_dir/$subdir"
70-
entrypoint_log "$ME: Running envsubst on $template to $output_path"
71+
entrypoint_log "$ME: info: Running envsubst on $template to $output_path"
7172
envsubst "$defined_envs" < "$template" > "$output_path"
7273
done
7374
fi

entrypoint/30-tune-worker-processes.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env/sh
22
# vim:sw=2:ts=2:sts=2:et
33

44
set -eu
@@ -9,7 +9,7 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
99

1010
[ "${NGINX_ENTRYPOINT_WORKER_PROCESSES_AUTOTUNE:-}" ] || exit 0
1111

12-
touch /etc/nginx/nginx.conf 2>/dev/null || { echo >&2 "$ME: error: can not modify /etc/nginx/nginx.conf (read-only file system?)"; exit 0; }
12+
touch /etc/nginx/nginx.conf 2>/dev/null || { echo >&2 "$ME: ERROR: Cannot modify /etc/nginx/nginx.conf (read-only file system?)"; exit 0; }
1313

1414
ceildiv() {
1515
num=$1
@@ -25,7 +25,7 @@ get_cpuset() {
2525
for token in $( tr ',' ' ' < "$cpusetroot/$cpusetfile" ); do
2626
case "$token" in
2727
*-*)
28-
count=$( seq $(echo "$token" | tr '-' ' ') | wc -l )
28+
count=$( seq "$(echo "$token" | tr '-' ' ')" | wc -l )
2929
ncpu=$(( ncpu+count ))
3030
;;
3131
*)

entrypoint/docker-entrypoint.sh

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
#!/bin/sh
2-
# vim:sw=4:ts=4:et
1+
#!/usr/bin/env/sh
2+
# vim:sw=2:ts=2:sts=2:et
33

44
set -e
55

66
entrypoint_log() {
7-
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
8-
echo "$@"
9-
fi
7+
if [ -z "${NGINX_ENTRYPOINT_QUIET_LOGS:-}" ]; then
8+
echo "$@"
9+
fi
1010
}
1111

12-
if [ "$1" = "nginx" -o "$1" = "nginx-debug" ]; then
13-
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
14-
entrypoint_log "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
12+
if [ "$1" = "nginx" ] || [ "$1" = "nginx-debug" ]; then
13+
if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
14+
entrypoint_log "$0: info: /docker-entrypoint.d/ is not empty, will attempt to perform configuration"
1515

16-
entrypoint_log "$0: Looking for shell scripts in /docker-entrypoint.d/"
17-
find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do
18-
case "$f" in
19-
*.envsh)
20-
if [ -x "$f" ]; then
21-
entrypoint_log "$0: Sourcing $f";
22-
. "$f"
23-
else
24-
# warn on shell scripts without exec bit
25-
entrypoint_log "$0: Ignoring $f, not executable";
26-
fi
27-
;;
28-
*.sh)
29-
if [ -x "$f" ]; then
30-
entrypoint_log "$0: Launching $f";
31-
"$f"
32-
else
33-
# warn on shell scripts without exec bit
34-
entrypoint_log "$0: Ignoring $f, not executable";
35-
fi
36-
;;
37-
*) entrypoint_log "$0: Ignoring $f";;
38-
esac
39-
done
16+
entrypoint_log "$0: info: Looking for shell scripts in /docker-entrypoint.d/"
17+
find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do
18+
case "$f" in
19+
*.envsh)
20+
if [ -x "$f" ]; then
21+
entrypoint_log "$0: info: Sourcing $f"
22+
. "$f"
23+
else
24+
# warn on shell scripts without exec bit
25+
entrypoint_log "$0: info: Ignoring $f, not executable"
26+
fi
27+
;;
28+
*.sh)
29+
if [ -x "$f" ]; then
30+
entrypoint_log "$0: info: Launching $f"
31+
"$f"
32+
else
33+
# warn on shell scripts without exec bit
34+
entrypoint_log "$0: info: Ignoring $f, not executable"
35+
fi
36+
;;
37+
*) entrypoint_log "$0: info: Ignoring $f" ;;
38+
esac
39+
done
4040

41-
entrypoint_log "$0: Configuration complete; ready for start up"
42-
else
43-
entrypoint_log "$0: No files found in /docker-entrypoint.d/, skipping configuration"
44-
fi
41+
entrypoint_log "$0: info: Configuration complete; ready for start up"
42+
else
43+
entrypoint_log "$0: info: No files found in /docker-entrypoint.d/, skipping configuration"
44+
fi
4545
fi
4646

4747
exec "$@"

mainline/alpine-perl/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,6 @@ RUN set -x \
7777
# remove checksum deps
7878
&& apk del --no-network .checksum-deps \
7979
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps)
80-
&& if [ -n "$tempDir" ]; then rm -rf "$tempDir"; fi \
81-
&& if [ -n "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
82-
&& if [ -n "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi
80+
&& if [ -f "$tempDir" ]; then rm -rf "$tempDir"; fi \
81+
&& if [ -f "/etc/apk/keys/abuild-key.rsa.pub" ]; then rm -f /etc/apk/keys/abuild-key.rsa.pub; fi \
82+
&& if [ -f "/etc/apk/keys/nginx_signing.rsa.pub" ]; then rm -f /etc/apk/keys/nginx_signing.rsa.pub; fi

0 commit comments

Comments
 (0)