Skip to content

Commit 3b2550b

Browse files
committed
support ipv4|[ipv6]|domain:port; fix Alpine grep P
(cherry picked from commit 1fde0ad)
1 parent 16c3c51 commit 3b2550b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

root/etc/cont-init.d/50-config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ if ! grep -Fxq "APP_KEY=${key}" /config/www/.env; then
5656
sed -i "s#^APP_KEY=.*#APP_KEY=${key}#" /config/www/.env
5757
fi
5858

59-
# if DB_HOST contains a port
60-
if echo "${DB_HOST}" | grep -qP '^(?:[0-9.]+|(?:\[[0-9a-fA-F:]+\]))(:[0-9]+)$'; then
59+
# if DB_HOST contains a port and DB_HOST is not a IPv6 without brackets [..]
60+
# support ipv4:port, [ipv6]:port, and domain:port
61+
if echo "$DB_HOST" | grep -qE ':[0-9]+$' && ! echo "$DB_HOST" | grep -qE '^(:{0,2}[a-fA-F0-9]{1,4})+$'; then
6162
DB_HOST_PORT="${DB_HOST}"
6263
fi
6364

0 commit comments

Comments
 (0)