Skip to content

Commit 808caad

Browse files
committed
fix: Use temp file for ipv6 conf checksum (#228)
The conf file was modified to change listen port in the Dockerfile, so to correctly compare packaged checksums we create a temporary file with the known changes reverted. This resolves an issue where the container would never listen on IPv6 on startup.
1 parent 74cdb36 commit 808caad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,21 @@ else
3737
fi
3838

3939
entrypoint_log "$ME: info: Getting the checksum of /$DEFAULT_CONF_FILE"
40+
# Use a temporary file to undo the port change so checksums can be compared.
41+
CONFTMP=$(mktemp)
42+
cat "/$DEFAULT_CONF_FILE" | sed 's,listen 8080;,listen 80;,' > $CONFTMP
4043

4144
case "$ID" in
4245
"debian")
4346
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 || {
47+
echo "$CHECKSUM $CONFTMP" | md5sum -c - >/dev/null 2>&1 || {
4548
entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version"
4649
exit 0
4750
}
4851
;;
4952
"alpine")
5053
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 || {
54+
echo "$CHECKSUM $CONFTMP" | sha1sum -c - >/dev/null 2>&1 || {
5255
entrypoint_log "$ME: info: /$DEFAULT_CONF_FILE differs from the packaged version"
5356
exit 0
5457
}
@@ -58,6 +61,7 @@ case "$ID" in
5861
exit 0
5962
;;
6063
esac
64+
rm "$CONFTMP"
6165

6266
# enable ipv6 on default.conf listen sockets
6367
sed -i -E 's,listen 8080;,listen 8080;\n listen [::]:8080;,' /$DEFAULT_CONF_FILE

0 commit comments

Comments
 (0)