From 1fde0ad70e72c73e8062f4a2d299d2cda9a46dc6 Mon Sep 17 00:00:00 2001 From: Tho Ho Date: Wed, 12 Oct 2022 02:37:19 +0800 Subject: [PATCH] support ipv4|[ipv6]|domain:port; fix Alpine grep P --- root/etc/cont-init.d/50-config | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/root/etc/cont-init.d/50-config b/root/etc/cont-init.d/50-config index 4ae8497..a920392 100644 --- a/root/etc/cont-init.d/50-config +++ b/root/etc/cont-init.d/50-config @@ -56,8 +56,9 @@ if ! grep -Fxq "APP_KEY=${key}" /config/www/.env; then sed -i "s#^APP_KEY=.*#APP_KEY=${key}#" /config/www/.env fi -# if DB_HOST contains a port -if echo "${DB_HOST}" | grep -qP '^(?:[0-9.]+|(?:\[[0-9a-fA-F:]+\]))(:[0-9]+)$'; then +# if DB_HOST contains a port and DB_HOST is not a IPv6 without brackets [..] +# support ipv4:port, [ipv6]:port, and domain:port +if echo "$DB_HOST" | grep -qE ':[0-9]+$' && ! echo "$DB_HOST" | grep -qE '^(:{0,2}[a-fA-F0-9]{1,4})+$'; then DB_HOST_PORT="${DB_HOST}" fi