Skip to content

Commit

Permalink
Input params - compare no/use-https and controller host protocols; Us…
Browse files Browse the repository at this point in the history
…e host if not matching;
  • Loading branch information
AlexJov committed Jan 20, 2021
1 parent 3a11eef commit 60ff116
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -813,18 +813,32 @@ _arg_user_credentials="$_arg_username@$_arg_account:$_arg_password"

# 3.2 Set protocol

# extract protocol based on input flags
if [ $_arg_use_https = true ]; then
protocol="https"
else
protocol="http"
fi

# extract protocol from controller host variable, without trailing :// and convert to lower caps
_arg_controller_host_protocol="$(echo $_arg_controller_host | grep :// | sed -e's,^\(.*://\).*,\1,g' | sed 's/.\{3\}$//' | tr '[:upper:]' '[:lower:]')"

# if host url does not contain protocol
if [ -z "${_arg_controller_host_protocol}" ]; then
_arg_controller_host_protocol=$protocol
fi

# 3.3 Prepare controller url

# remove anything before // (protocol) and after : or / (path and/or port) in hostname - to keep only domain name
_arg_controller_host="$(echo $_arg_controller_host | sed -e 's|^[^/]*//||' -e 's|/.*$||' -e 's|:.*$||')"

_arg_controller_url="$protocol://$_arg_controller_host:$_arg_controller_port/controller"
_arg_controller_url="$_arg_controller_host_protocol://$_arg_controller_host:$_arg_controller_port/controller"

if [ "${protocol}" != "${_arg_controller_host_protocol}" ]; then
echo "WARNING --use-https / --no-use-https flag value '${protocol}' does not match controller host protocol '${_arg_controller_host_protocol}'."
echo " Note that controller host protocol takes precedence and final URL to connect to is: '${_arg_controller_url}'."
fi

# 3.4 Prepare proxy details

Expand Down

0 comments on commit 60ff116

Please sign in to comment.