mirror of https://github.com/samply/bridgehead.git
Rewrote proxy detection logic to deal with all combinations of no/authenticated/unauthenticated proxy servers
This commit is contained in:
parent
68cd62b981
commit
74817a21da
|
@ -10,19 +10,34 @@ detectCompose() {
|
||||||
}
|
}
|
||||||
|
|
||||||
setupProxy() {
|
setupProxy() {
|
||||||
|
http="no"
|
||||||
|
if [ $HTTP_PROXY_URL ]; then
|
||||||
if [[ ! -z "$HTTP_PROXY_USERNAME" && ! -z "$HTTP_PROXY_PASSWORD" ]]; then
|
if [[ ! -z "$HTTP_PROXY_USERNAME" && ! -z "$HTTP_PROXY_PASSWORD" ]]; then
|
||||||
log "INFO" "Detected proxy user and password"
|
proto="$(echo $HTTP_PROXY_URL | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
||||||
HTTP_PROXY_PROTOCOL="$(echo $HTTP_PROXY_URL | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
fqdn="$(echo ${HTTP_PROXY_URL/$proto/})"
|
||||||
HTTP_PROXY_FQDN="$(echo ${HTTP_PROXY_URL/$HTTP_PROXY_PROTOCOL/})"
|
HTTP_PROXY_FULL_URL="$(echo $proto$HTTP_PROXY_USERNAME:$HTTP_PROXY_PASSWORD@$fqdn)"
|
||||||
HTTP_PROXY_FULL_URL="$(echo $HTTP_PROXY_PROTOCOL$HTTP_PROXY_USERNAME:$HTTP_PROXY_PASSWORD@$HTTP_PROXY_FQDN)"
|
http="authenticated"
|
||||||
|
|
||||||
HTTPS_PROXY_PROTOCOL="$(echo $HTTPS_PROXY_URL | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
|
||||||
HTTPS_PROXY_FQDN="$(echo ${HTTPS_PROXY_URL/$HTTPS_PROXY_PROTOCOL/})"
|
|
||||||
HTTPS_PROXY_FULL_URL="$(echo $HTTPS_PROXY_PROTOCOL$HTTP_PROXY_USERNAME:$HTTP_PROXY_PASSWORD@$HTTPS_PROXY_FQDN)"
|
|
||||||
else
|
else
|
||||||
HTTP_PROXY_FULL_URL=$HTTP_PROXY_URL
|
HTTP_PROXY_FULL_URL=$HTTP_PROXY_URL
|
||||||
HTTPS_PROXY_FULL_URL=$HTTPS_PROXY_URL
|
http="unauthenticated"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
https="no"
|
||||||
|
if [ $HTTPS_PROXY_URL ]; then
|
||||||
|
if [[ ! -z "$HTTPS_PROXY_USERNAME" && ! -z "$HTTPS_PROXY_PASSWORD" ]]; then
|
||||||
|
proto="$(echo $HTTPS_PROXY_URL | grep :// | sed -e's,^\(.*://\).*,\1,g')"
|
||||||
|
fqdn="$(echo ${HTTPS_PROXY_URL/$proto/})"
|
||||||
|
HTTPS_PROXY_FULL_URL="$(echo $proto$HTTPS_PROXY_USERNAME:$HTTPS_PROXY_PASSWORD@$fqdn)"
|
||||||
|
https="authenticated"
|
||||||
|
else
|
||||||
|
HTTPS_PROXY_FULL_URL=$HTTPS_PROXY_URL
|
||||||
|
https="unauthenticated"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
log INFO "Configuring proxy servers: $http http proxy, $https https proxy"
|
||||||
|
unset http https fqdn proto
|
||||||
}
|
}
|
||||||
|
|
||||||
exitIfNotRoot() {
|
exitIfNotRoot() {
|
||||||
|
|
|
@ -50,8 +50,7 @@ for DIR in /etc/bridgehead $(pwd); do
|
||||||
git -C $DIR config credential.helper "$CREDHELPER"
|
git -C $DIR config credential.helper "$CREDHELPER"
|
||||||
fi
|
fi
|
||||||
old_git_hash="$(git -C $DIR rev-parse --verify HEAD)"
|
old_git_hash="$(git -C $DIR rev-parse --verify HEAD)"
|
||||||
if [ -z "$HTTP_PROXY_URL" ]; then
|
if [ -z "$HTTP_PROXY_FULL_URL" ]; then
|
||||||
log "INFO" "Git is using no proxy!"
|
|
||||||
OUT=$(retry 5 git -C $DIR fetch 2>&1 && retry 5 git -C $DIR pull 2>&1)
|
OUT=$(retry 5 git -C $DIR fetch 2>&1 && retry 5 git -C $DIR pull 2>&1)
|
||||||
else
|
else
|
||||||
log "INFO" "Git is using proxy ${HTTP_PROXY_URL} from ${CONFFILE}"
|
log "INFO" "Git is using proxy ${HTTP_PROXY_URL} from ${CONFFILE}"
|
||||||
|
|
Loading…
Reference in New Issue