Add the IPv6 listener once, so a restarted console starts #139
No files matched your search
@@ -71,6 +71,7 @@ jobs:
|
||||
- run: npm run i18n:check
|
||||
- run: npm test
|
||||
- run: sh tools/release-version.test.sh
|
||||
- run: sh docker/listen-ipv6.test.sh
|
||||
- run: npm run build
|
||||
|
||||
# A changed upstream file without the AGPL 5(a) notice, as inbuxa-server's
|
||||
|
||||
@@ -8,10 +8,16 @@
|
||||
# open.
|
||||
set -eu
|
||||
|
||||
conf=/etc/nginx/conf.d/default.conf
|
||||
# Both paths can be moved for docker/listen-ipv6.test.sh.
|
||||
conf=${NGINX_CONF:-/etc/nginx/conf.d/default.conf}
|
||||
if_inet6=${IF_INET6:-/proc/net/if_inet6}
|
||||
|
||||
[ -f /proc/net/if_inet6 ] || { echo "no IPv6 on this host, listening on IPv4 only"; exit 0; }
|
||||
grep -q 'listen \[::\]:8080' "$conf" && exit 0
|
||||
[ -f "$if_inet6" ] || { echo "no IPv6 on this host, listening on IPv4 only"; exit 0; }
|
||||
# A restarted container keeps the file as the last start left it, so the
|
||||
# listener may be there already: nginx refuses a duplicate listen and the
|
||||
# container would restart in a loop. The line below is written with several
|
||||
# spaces after "listen", so match any number.
|
||||
grep -q 'listen *\[::\]:8080;' "$conf" && exit 0
|
||||
|
||||
# Written back through the file, as 40-api-base-url.sh does with index.html:
|
||||
# conf.d belongs to root, the file to the nginx user.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Tests for listen-ipv6.sh: sh docker/listen-ipv6.test.sh
|
||||
set -u
|
||||
here=$(dirname "$0"); fail=0
|
||||
dir=$(mktemp -d); trap 'rm -rf "$dir"' EXIT
|
||||
cp "$here/nginx.conf" "$dir/default.conf"; : > "$dir/if_inet6"
|
||||
run() { NGINX_CONF="$dir/default.conf" IF_INET6="$1" sh "$here/listen-ipv6.sh" >/dev/null; }
|
||||
listeners() { grep -c 'listen *\[::\]:8080;' "$dir/default.conf"; }
|
||||
|
||||
run "$dir/none"
|
||||
[ "$(listeners)" = 0 ] || { echo "FAIL: added an IPv6 listener without IPv6"; fail=1; }
|
||||
run "$dir/if_inet6"
|
||||
[ "$(listeners)" = 1 ] || { echo "FAIL: first start -> $(listeners) IPv6 listeners, want 1"; fail=1; }
|
||||
# A restart of the same container runs the script again on the file it left.
|
||||
run "$dir/if_inet6"; run "$dir/if_inet6"
|
||||
[ "$(listeners)" = 1 ] || { echo "FAIL: after restarts -> $(listeners) IPv6 listeners, want 1"; fail=1; }
|
||||
[ "$(grep -c 'listen *8080;' "$dir/default.conf")" = 1 ] || { echo "FAIL: the IPv4 listener changed"; fail=1; }
|
||||
[ $fail = 0 ] && echo "listen-ipv6: ok"
|
||||
exit $fail
|
||||
Reference in new issue
Block a user