echo"**** Entering docker container ${DOCKER_ID}, exit with Ctrl-D"
echo -n " ... cleanup docker: "
docker rm -f "${DOCKER_ID}"
echo"returning status: $e"
echo"--->"
exit$e
fi
done
echo -n " SUCCESS ... cleanup docker: "
docker rm -f "${DOCKER_ID}"
exit0
}
function ifthenelse(){
function ifthenelse(){
arg="$1"
arg="$1"
shift
shift
@ -103,24 +136,29 @@ function ifthenelse() {
os="${arg%%:::*}"
os="${arg%%:::*}"
thenpart="${arg#*:::}"
thenpart="${arg#*:::}"
iftest"${thenpart/:::/}"="${thenpart}";then
iftest"${thenpart/:::/}"="${thenpart}";then
docker exec${DOCKER_ID} bash -c 'os="'$os'"; if test "${os//$(lsb_release -is)/}${os//$(lsb_release -cs)/}" != "${os}${os}"; then '"${cmd//ARG/${thenpart}}"'; fi'
docker exec${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; fi'
else
else
elsepart="${thenpart##*:::}"
elsepart="${thenpart##*:::}"
thenpart="${thenpart%:::*}"
thenpart="${thenpart%:::*}"
docker exec${DOCKER_ID} bash -c 'os="'$os'"; if test "${os//$(lsb_release -is)/}${os//$(lsb_release -cs)/}" != "${os}${os}"; then '"${cmd//ARG/${thenpart}}"'; else '"${cmd//ARG/${elsepart}}"'; fi'
iftest -n "${thenpart}";then
docker exec${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)" =~ ${os} ]]; then '"${cmd//ARG/${thenpart}}"'; else '"${cmd//ARG/${elsepart}}"'; fi'
else
docker exec${DOCKER_ID} bash -c 'os="'$os'"; if [[ "$(lsb_release -is)-$(lsb_release -cs)" =~ ${os} ]]; then true; else '"${cmd//ARG/${elsepart}}"'; fi'
fi
fi
fi
fi
fi
}
}
set -x
set -x
docker pull $img
DOCKER_ID=$(docker run -d ${dirs[@]}${envs[@]} -w /workdir $img sleep infinity)
DOCKER_ID=$(docker run -d ${dirs[@]}${envs[@]} -w /workdir $img sleep infinity)
trap"docker rm -f ${DOCKER_ID}" INT TERM EXIT
trap'traperror '"${DOCKER_ID}"' "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' SIGINT INT TERM EXIT