Fix install issue with default hostname commented

Update the `grep` filter to anchor at the start of the line
and allow for whitespace characters, in order to correctly
determine the hostname being set if the default is merely
commented out and the custom one added, instead of overridden.

Fixes #6117

Signed-off-by: Christian Witts <cwitts@gmail.com>
This commit is contained in:
Christian Witts 2018-10-23 14:55:27 +02:00
parent 2920ec5f9b
commit e9c01255da
No known key found for this signature in database
GPG Key ID: 115B2092ADDF055A

View File

@ -84,7 +84,7 @@ workdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $workdir
# The hostname in harbor.cfg has not been modified
if grep 'hostname = reg.mydomain.com' &> /dev/null harbor.cfg
if grep '^[[:blank:]]*hostname = reg.mydomain.com' &> /dev/null harbor.cfg
then
warn "$usage"
exit 1
@ -212,7 +212,7 @@ then
protocol=${BASH_REMATCH[1]}
fi
if [[ $(grep 'hostname[[:blank:]]*=' ./harbor.cfg) =~ hostname[[:blank:]]*=[[:blank:]]*(.*) ]]
if [[ $(grep '^[[:blank:]]*hostname[[:blank:]]*=' ./harbor.cfg) =~ hostname[[:blank:]]*=[[:blank:]]*(.*) ]]
then
hostname=${BASH_REMATCH[1]}
fi