summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2017-02-08 16:08:32 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2017-02-08 16:08:32 +0000
commitc219fac91e13b89fd95994abacd6129cb09ffe06 (patch)
tree728b72c6e8eaf1e35a85fa5ca8176705e0ce561c
parentf33002a6126f721fb5e55c0f83f0afe321bb3cb8 (diff)
start-container-*.sh: Define CONTAINER_CLEANUP instead of installing a trap.
It was not possible to create 2 containers with these scripts and benefit from automatic cleanup via a trap handler: the 2nd one would override the 1st one. With this patch, we define CONTAINER_CLEANUP which contains the cleanup command, which can be saved by the caller script and used as needed. Change-Id: I832395baeb6dda2c89a4fa7d29e68017df6c628f
-rwxr-xr-xstart-container-docker.sh4
-rwxr-xr-xstart-container-none.sh3
-rwxr-xr-xstart-container-schroot.sh4
3 files changed, 6 insertions, 5 deletions
diff --git a/start-container-docker.sh b/start-container-docker.sh
index 45f2ceb0..320df03d 100755
--- a/start-container-docker.sh
+++ b/start-container-docker.sh
@@ -6,7 +6,7 @@ set -e
# This script is meant to be executed from Jenkins jobs inside TCWG
# lab. It prints shell commands meant to be executed in the parent
# shell, consisting in:
-# - a trap statement, to cleanup the container upon exit
+# - a cleanup statement, to remove the container on exit for instance
# - definition of ${CONTAINER}, used to prefix commands that you want
# to run inside the container.
# - definition of ${session_host} and ${session_port}, can be used for
@@ -146,8 +146,8 @@ trap EXIT
exec 1>&3 2>&4
cat <<EOF
-trap "$DOCKER rm -fv $session_id" EXIT
CONTAINER="ssh -p $session_port -A $session_host"
+CONTAINER_CLEANUP="$DOCKER rm -fv $session_id"
session_host=${session_host}
session_port=${session_port}
EOF
diff --git a/start-container-none.sh b/start-container-none.sh
index 744810df..a77fd876 100755
--- a/start-container-none.sh
+++ b/start-container-none.sh
@@ -8,7 +8,7 @@ set -e
# This script is meant to be executed from Jenkins jobs inside TCWG
# lab. It prints shell commands meant to be executed in the parent
# shell, consisting in:
-# - a trap statement, to cleanup the container upon exit
+# - a cleanup statement, to remove the container on exit for instance
# - definition of ${CONTAINER}, used to prefix commands that you want
# to run inside the container.
# - definition of ${session_host} and ${session_port}, can be used for
@@ -104,6 +104,7 @@ exec 1>&3 2>&4
cat <<EOF
ulimit -u 5000
CONTAINER="ssh -p ${session_port} -A ${session_host}"
+CONTAINER_CLEANUP=""
session_host=${session_host}
session_port=${session_port}
EOF
diff --git a/start-container-schroot.sh b/start-container-schroot.sh
index 3fdc5727..475be412 100755
--- a/start-container-schroot.sh
+++ b/start-container-schroot.sh
@@ -6,7 +6,7 @@ set -e
# This script is meant to be executed from Jenkins jobs inside TCWG
# lab. It prints shell commands meant to be executed in the parent
# shell, consisting in:
-# - a trap statement, to cleanup the container upon exit
+# - a cleanup statement, to remove the container on exit for instance
# - definition of ${CONTAINER}, used to prefix commands that you want
# to run inside the container.
# - definition of ${session_host} and ${session_port}, can be used for
@@ -86,8 +86,8 @@ cat <<EOF
ulimit -u 5000 # FIXME how to support this remotely?
# Sometimes /dev/pts can't get unmounted on the first try.
# Workaround by retrying.
-trap "{ ${SCHROOT} -f -e -c session:$session_id || { sleep 60 ; ${SCHROOT} -f -e -c session:$session_id; } || true; }" EXIT
CONTAINER="${SCHROOT} -r -c session:$session_id --preserve-environment -- "
+CONTAINER_CLEANUP="${SCHROOT} -f -e -c session:$session_id"
session_host=${session_host}
session_port=${session_port}
EOF