From 85446b0a3edd4a1ff4e34d9837a8aa52380c5b1f Mon Sep 17 00:00:00 2001 From: Patrick Skowronek Date: Mon, 9 Oct 2023 09:43:30 +0200 Subject: [PATCH] Added SECURE_PROXY if the https and http proxy are the same --- lib/functions.sh | 7 ++++++- lib/monitoring.sh | 4 ++-- lib/prerequisites.sh | 2 +- lib/update-bridgehead.sh | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/functions.sh b/lib/functions.sh index 0163b1c..15d9aed 100644 --- a/lib/functions.sh +++ b/lib/functions.sh @@ -3,7 +3,7 @@ detectCompose() { if [[ "$(docker compose version 2>/dev/null)" == *"Docker Compose version"* ]]; then COMPOSE="docker compose" - else + e COMPOSE="docker-compose" # This is intended to fail on startup in the next prereq check. fi @@ -15,8 +15,13 @@ setupProxy() { PROTO="$(echo $HTTP_PROXY_URL | grep :// | sed -e's,^\(.*://\).*,\1,g')" URL="$(echo ${HTTP_PROXY_URL/$PROTO/})" PROXY="$(echo $PROTO$HTTP_PROXY_USERNAME:$HTTP_PROXY_PASSWORD@$URL)" + + SECURE_PROTO="$(echo $HTTPS_PROXY_URL | grep :// | sed -e's,^\(.*://\).*,\1,g')" + SECURE_URL="$(echo ${HTTPS_PROXY_URL/$SECURE_PROTO/})" + SECURE_PROXY="$(echo $SECURE_PROTO$HTTP_PROXY_USERNAME:$HTTP_PROXY_PASSWORD@$SECURE_URL)" else PROXY=$HTTP_PROXY_URL + SECURE_PROXY=$HTTPS_PROXY_URL fi } diff --git a/lib/monitoring.sh b/lib/monitoring.sh index 1b12272..c4b3fad 100755 --- a/lib/monitoring.sh +++ b/lib/monitoring.sh @@ -47,8 +47,8 @@ function hc_send(){ if [ -n "$2" ]; then MSG="$2\n\nDocker stats:\n$UPTIME" - echo -e "$MSG" | https_proxy=$PROXY curl --max-time 5 -A "$USER_AGENT" -s -o /dev/null -X POST --data-binary @- "$HCURL"/"$1" || log WARN "Monitoring failed: Unable to send data to $HCURL/$1" + echo -e "$MSG" | https_proxy=$SECURE_PROXY curl --max-time 5 -A "$USER_AGENT" -s -o /dev/null -X POST --data-binary @- "$HCURL"/"$1" || log WARN "Monitoring failed: Unable to send data to $HCURL/$1" else - https_proxy=$PROXY curl --max-time 5 -A "$USER_AGENT" -s -o /dev/null "$HCURL"/"$1" || log WARN "Monitoring failed: Unable to send data to $HCURL/$1" + https_proxy=$SECURE_PROXY curl --max-time 5 -A "$USER_AGENT" -s -o /dev/null "$HCURL"/"$1" || log WARN "Monitoring failed: Unable to send data to $HCURL/$1" fi } diff --git a/lib/prerequisites.sh b/lib/prerequisites.sh index 3140a2c..5a9372f 100755 --- a/lib/prerequisites.sh +++ b/lib/prerequisites.sh @@ -68,7 +68,7 @@ source /etc/bridgehead/${PROJECT}.conf source ${PROJECT}/vars set +e -SERVERTIME="$(https_proxy=$PROXY curl -m 5 -s -I $BROKER_URL_FOR_PREREQ 2>&1 | grep -i -e '^Date: ' | sed -e 's/^Date: //i')" +SERVERTIME="$(https_proxy=$SECURE_PROXY curl -m 5 -s -I $BROKER_URL_FOR_PREREQ 2>&1 | grep -i -e '^Date: ' | sed -e 's/^Date: //i')" RET=$? set -e if [ $RET -ne 0 ]; then diff --git a/lib/update-bridgehead.sh b/lib/update-bridgehead.sh index 37ac8cd..5620261 100755 --- a/lib/update-bridgehead.sh +++ b/lib/update-bridgehead.sh @@ -55,7 +55,7 @@ for DIR in /etc/bridgehead $(pwd); do OUT=$(retry 5 git -C $DIR fetch 2>&1 && retry 5 git -C $DIR pull 2>&1) else log "INFO" "Git is using proxy ${HTTP_PROXY_URL} from ${CONFFILE}" - OUT=$(retry 5 git -c http.proxy=$PROXY -c https.proxy=$PROXY -C $DIR fetch 2>&1 && retry 5 git -c http.proxy=$PROXY -c https.proxy=$PROXY -C $DIR pull 2>&1) + OUT=$(retry 5 git -c http.proxy=$PROXY -c https.proxy=$SECURE_PROXY -C $DIR fetch 2>&1 && retry 5 git -c http.proxy=$PROXY -c https.proxy=$SECURE_PROXY -C $DIR pull 2>&1) fi if [ $? -ne 0 ]; then report_error log "Unable to update git $DIR: $OUT"