From de36d53208cb253e0dbbd32d1623558d853d3406 Mon Sep 17 00:00:00 2001 From: Dvir Naim Date: Sun, 1 Oct 2023 14:04:23 +0300 Subject: [PATCH] fix hostnetwork in update --- Solutions/SAP/sapcon-instance-update.sh | 13 ++++++++++--- Solutions/SAP/sapcon-sentinel-kickstart.sh | 4 ++-- Solutions/SAP/sapcon-sentinel-ui-agent-kickstart.sh | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Solutions/SAP/sapcon-instance-update.sh b/Solutions/SAP/sapcon-instance-update.sh index f4810583fc7..41d2e8c14a9 100755 --- a/Solutions/SAP/sapcon-instance-update.sh +++ b/Solutions/SAP/sapcon-instance-update.sh @@ -59,6 +59,10 @@ while [[ $# -gt 0 ]]; do DEVURL="$2" shift 2 ;; + --hostnetwork) + HOSTNETWORK=1 + shift 1 + ;; --dev-acr-login) DEVACRLOGIN="$2" shift 2 @@ -203,6 +207,7 @@ while IFS= read -r contname; do fi read -r -a containervariables <<<$(docker inspect "$contname" --format '{{.Config.Env}}' | tr -d '[' | tr -d ']' | tr ' ' ' ') envstring="" + cmdparams="" for variable in "${containervariables[@]}"; do if [[ ! $variable == PATH=* ]] && [[ ! $variable == LANG=* ]] && @@ -265,12 +270,14 @@ while IFS= read -r contname; do docker cp "$contname":$sdkfileloc "/tmp/sapcon-update/$contname/inst/" fi sdkfilename=$(ls -1r /tmp/sapcon-update/$contname/inst/nwrfc*.zip | head -n 1) - + if [ $HOSTNETWORK ]; then + cmdparams+=" --network host " + fi if [ ! $NOTESTRUN ]; then # If test run is required testruncontainer="$contname-testrun" log "Creating agent $contname in test mode" - docker create -v "$sysfileloc:/sapcon-app/sapcon/config/system" $envstring $ContainerNetworkSetting --name "$testruncontainer" $dockerimage$tagver --sapconinstanceupdate >/dev/null + docker create -v "$sysfileloc:/sapcon-app/sapcon/config/system" $cmdparams $envstring $ContainerNetworkSetting --name "$testruncontainer" $dockerimage$tagver --sapconinstanceupdate >/dev/null docker cp "$sdkfilename" "$testruncontainer":$sdkfileloc docker start "$testruncontainer" >/dev/null @@ -344,7 +351,7 @@ while IFS= read -r contname; do if [ $dryrunsuccess == 1 ]; then log "Creating updated agent $contname" labelstring="--label Cloud=$CLOUD " - docker create -v "$sysfileloc:/sapcon-app/sapcon/config/system" $envstring $labelstring $restartpolicystring $ContainerNetworkSetting --name "$contname" $dockerimage$tagver >/dev/null + docker create -v "$sysfileloc:/sapcon-app/sapcon/config/system" $cmdparams $envstring $labelstring $restartpolicystring $ContainerNetworkSetting --name "$contname" $dockerimage$tagver >/dev/null docker cp "$sdkfilename" "$contname":"$sdkfileloc" fi #Cleaning sapcon-update folder diff --git a/Solutions/SAP/sapcon-sentinel-kickstart.sh b/Solutions/SAP/sapcon-sentinel-kickstart.sh index 64852cce9c6..ec1957451b4 100755 --- a/Solutions/SAP/sapcon-sentinel-kickstart.sh +++ b/Solutions/SAP/sapcon-sentinel-kickstart.sh @@ -118,7 +118,7 @@ while [[ $# -gt 0 ]]; do SID="$2" shift 2 ;; - --hostnetwork) + --hostnetwork) HOSTNETWORK=1 shift 1 ;; @@ -793,7 +793,7 @@ cmdparams=" --label Cloud=$CLOUD" cmdparams+=" -e SENTINEL_AGENT_GUID=$(uuidgen) " if [ $HOSTNETWORK ]; then - cmdparams+=" --network host" + cmdparams+=" --network host " fi if [ "$MODE" == "kvmi" ]; then diff --git a/Solutions/SAP/sapcon-sentinel-ui-agent-kickstart.sh b/Solutions/SAP/sapcon-sentinel-ui-agent-kickstart.sh index 9e9187f3301..034bc543b67 100644 --- a/Solutions/SAP/sapcon-sentinel-ui-agent-kickstart.sh +++ b/Solutions/SAP/sapcon-sentinel-ui-agent-kickstart.sh @@ -430,7 +430,7 @@ elif [ "$MODE" == "kvsi" ]; then cmdparams+=" -e AZURE_CLIENT_ID=$APPID -e AZURE_CLIENT_SECRET=$APPSECRET -e AZURE_TENANT_ID=$TENANT" fi if [ $HOSTNETWORK ]; then - cmdparams+=" --network host" + cmdparams+=" --network host " fi sudo docker create -v "$sysfileloc":/sapcon-app/sapcon/config/system $cmdparams --name "$containername" $dockerimage$tagver >/dev/null