Skip to content
Snippets Groups Projects
Commit 41e6b2c6 authored by Konstantin Pavlov's avatar Konstantin Pavlov
Browse files

ipv6-listen: deal with edge cases and fixes

- remove undefined behaviour from the if statements
- exit early if a file already has an ipv6 listen
- fixed md5sum check
parent 6c7dde57
No related branches found
No related tags found
No related merge requests found
......@@ -7,21 +7,19 @@ ME=$(basename $0)
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
# check if we have ipv6 available
if [ -f "/proc/net/if_inet6" ]; then
continue
else
if [ ! -f "/proc/net/if_inet6" ]; then
echo "$ME: ipv6 not available, exiting" 1>&2
exit 0
fi
if [ -f "/$DEFAULT_CONF_FILE" ]; then
continue
else
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
echo "$ME: /$DEFAULT_CONF_FILE is not a file or does not exist, exiting" 1>&2
exit 0
fi
# check if the file is already modified, e.g. on a container restart
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
......
......@@ -7,21 +7,19 @@ ME=$(basename $0)
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
# check if we have ipv6 available
if [ -f "/proc/net/if_inet6" ]; then
continue
else
if [ ! -f "/proc/net/if_inet6" ]; then
echo "$ME: ipv6 not available, exiting" 1>&2
exit 0
fi
if [ -f "/$DEFAULT_CONF_FILE" ]; then
continue
else
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
echo "$ME: /$DEFAULT_CONF_FILE is not a file or does not exist, exiting" 1>&2
exit 0
fi
# check if the file is already modified, e.g. on a container restart
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
......
......@@ -7,21 +7,19 @@ ME=$(basename $0)
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
# check if we have ipv6 available
if [ -f "/proc/net/if_inet6" ]; then
continue
else
if [ ! -f "/proc/net/if_inet6" ]; then
echo "$ME: ipv6 not available, exiting" 1>&2
exit 0
fi
if [ -f "/$DEFAULT_CONF_FILE" ]; then
continue
else
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
echo "$ME: /$DEFAULT_CONF_FILE is not a file or does not exist, exiting" 1>&2
exit 0
fi
# check if the file is already modified, e.g. on a container restart
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
......
......@@ -7,21 +7,19 @@ ME=$(basename $0)
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
# check if we have ipv6 available
if [ -f "/proc/net/if_inet6" ]; then
continue
else
if [ ! -f "/proc/net/if_inet6" ]; then
echo "$ME: ipv6 not available, exiting" 1>&2
exit 0
fi
if [ -f "/$DEFAULT_CONF_FILE" ]; then
continue
else
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
echo "$ME: /$DEFAULT_CONF_FILE is not a file or does not exist, exiting" 1>&2
exit 0
fi
# check if the file is already modified, e.g. on a container restart
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
......
......@@ -7,21 +7,19 @@ ME=$(basename $0)
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
# check if we have ipv6 available
if [ -f "/proc/net/if_inet6" ]; then
continue
else
if [ ! -f "/proc/net/if_inet6" ]; then
echo "$ME: ipv6 not available, exiting" 1>&2
exit 0
fi
if [ -f "/$DEFAULT_CONF_FILE" ]; then
continue
else
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
echo "$ME: /$DEFAULT_CONF_FILE is not a file or does not exist, exiting" 1>&2
exit 0
fi
# check if the file is already modified, e.g. on a container restart
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
......
......@@ -7,21 +7,19 @@ ME=$(basename $0)
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
# check if we have ipv6 available
if [ -f "/proc/net/if_inet6" ]; then
continue
else
if [ ! -f "/proc/net/if_inet6" ]; then
echo "$ME: ipv6 not available, exiting" 1>&2
exit 0
fi
if [ -f "/$DEFAULT_CONF_FILE" ]; then
continue
else
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
echo "$ME: /$DEFAULT_CONF_FILE is not a file or does not exist, exiting" 1>&2
exit 0
fi
# check if the file is already modified, e.g. on a container restart
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
......
......@@ -7,21 +7,19 @@ ME=$(basename $0)
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
# check if we have ipv6 available
if [ -f "/proc/net/if_inet6" ]; then
continue
else
if [ ! -f "/proc/net/if_inet6" ]; then
echo "$ME: ipv6 not available, exiting" 1>&2
exit 0
fi
if [ -f "/$DEFAULT_CONF_FILE" ]; then
continue
else
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
echo "$ME: /$DEFAULT_CONF_FILE is not a file or does not exist, exiting" 1>&2
exit 0
fi
# check if the file is already modified, e.g. on a container restart
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
......
......@@ -7,21 +7,19 @@ ME=$(basename $0)
DEFAULT_CONF_FILE="etc/nginx/conf.d/default.conf"
# check if we have ipv6 available
if [ -f "/proc/net/if_inet6" ]; then
continue
else
if [ ! -f "/proc/net/if_inet6" ]; then
echo "$ME: ipv6 not available, exiting" 1>&2
exit 0
fi
if [ -f "/$DEFAULT_CONF_FILE" ]; then
continue
else
if [ ! -f "/$DEFAULT_CONF_FILE" ]; then
echo "$ME: /$DEFAULT_CONF_FILE is not a file or does not exist, exiting" 1>&2
exit 0
fi
# check if the file is already modified, e.g. on a container restart
grep -q "listen \[::]\:80;" /$DEFAULT_CONF_FILE && { echo "$ME: IPv6 listen already enabled, exiting"; exit 0; }
if [ -f "/etc/os-release" ]; then
. /etc/os-release
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment