From b8e5118d18152f79176ae9b56da0dc0ab416e94b Mon Sep 17 00:00:00 2001 From: Serhii Prodan Date: Fri, 28 Apr 2023 10:36:03 +0200 Subject: [PATCH] Set -euxE and pipefail for context sh scripts --- context/run-agent-services.sh | 3 +++ context/run-agent.sh | 3 +++ context/run-docker.sh | 4 ++++ context/run-server-services.sh | 4 +++- context/run-server.sh | 5 ++++- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/context/run-agent-services.sh b/context/run-agent-services.sh index a574dd68a..966070acc 100644 --- a/context/run-agent-services.sh +++ b/context/run-agent-services.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -euxE +set -o pipefail + echo '/run-services.sh' for entry in /services/*.sh diff --git a/context/run-agent.sh b/context/run-agent.sh index 7107c5a8a..0414d7e9c 100644 --- a/context/run-agent.sh +++ b/context/run-agent.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -euxE +set -o pipefail + check() { if [[ $? != 0 ]]; then echo "Error! Stopping the script." diff --git a/context/run-docker.sh b/context/run-docker.sh index d056de826..f59bba74a 100644 --- a/context/run-docker.sh +++ b/context/run-docker.sh @@ -1,5 +1,9 @@ #!/bin/bash +set -euxE +set -o pipefail + + if [ "$DOCKER_IN_DOCKER" = "start" ] ; then # Do cover the case when the container is restarted: diff --git a/context/run-server-services.sh b/context/run-server-services.sh index f412a599a..62767d038 100644 --- a/context/run-server-services.sh +++ b/context/run-server-services.sh @@ -1,6 +1,8 @@ #!/bin/bash + # Fail if one of the service scripts fail -set -e +set -euxE +set -o pipefail echo '/run-services.sh' diff --git a/context/run-server.sh b/context/run-server.sh index de58c840f..e6d6a1a53 100644 --- a/context/run-server.sh +++ b/context/run-server.sh @@ -1,5 +1,8 @@ #!/bin/bash +set -euxE +set -o pipefail + # Setting default values if variables not present : ${TEAMCITY_DIST:=/opt/teamcity} : ${TEAMCITY_LOGS:=${TEAMCITY_DIST}/logs} @@ -27,4 +30,4 @@ cd "${TEAMCITY_DIST}" echo "TeamCity server.xml parameter: $TEAMCITY_SERVER_XML" bin/teamcity-server.sh run $TEAMCITY_SERVER_XML & wait $! -exit $? \ No newline at end of file +exit $?