@@ -143,26 +143,32 @@ function configure_app()
143143function set-nc-domain()
144144{
145145 local domain=" ${1?} "
146- domain=" $( sed ' s|http.\?://||;s|\(/.*\)||' <<< " ${domain}" ) "
147- if ! ping -c1 -w1 -q " ${domain} " & > /dev/null; then
146+ local proto=" ${domain%://* } "
147+ domain=" ${domain#*:// } " # strip protocol
148+ local host=" ${domain%%/* } " # strip path
149+ local port=" ${domain#*: } "
150+ host=" ${host%:* } " # strip port
151+ if ! ping -c1 -w1 -q " ${host} " & > /dev/null; then
148152 unset domain
153+ unset host
154+ unset proto
155+ unset port
149156 fi
150157 if [[ " ${domain} " == " " ]] || is_an_ip " ${domain} " ; then
151158 echo " warning: No domain found. Defaulting to '$( hostname) '"
152159 domain=" $( hostname) "
153160 fi
154- local proto
155- proto=" $( ncc config:system:get overwriteprotocol) " || true
156- [[ " ${proto} " == " " ]] && proto=" https"
157- local url=" ${proto} ://${domain%*/ } "
161+ [[ -n " $proto " ]] || proto=" $( ncc config:system:get overwriteprotocol) " || true
162+ [[ -z " $port " ]] || port=" :$port "
163+ local url=" ${proto:- https} ://${host%/* }${port:- } "
158164 [[ " $2 " == " --no-trusted-domain" ]] || ncc config:system:set trusted_domains 3 --value=" ${domain%*/ } "
159165 ncc config:system:set overwrite.cli.url --value=" ${url} /"
160166 if is_ncp_activated && is_app_enabled notify_push; then
161167 ncc config:system:set trusted_proxies 11 --value=" 127.0.0.1"
162168 ncc config:system:set trusted_proxies 12 --value=" ::1"
163169# ncc config:system:set trusted_proxies 13 --value="${domain}"
164- local domain_ip=" $( dig +short " ${domain } " ) "
165- [[ -z " $domain_ip " ]] || ncc config:system:set trusted_proxies 14 --value=" $( dig +short " ${domain } " ) "
170+ local domain_ip=" $( dig +short " ${host } " ) "
171+ [[ -z " $domain_ip " ]] || ncc config:system:set trusted_proxies 14 --value=" $( dig +short " ${host } " ) "
166172 sleep 5 # this seems to be required in the VM for some reason. We get `http2 error: protocol error` after ncp-upgrade-nc
167173 for try in {1..5}
168174 do
0 commit comments