build: run run.sh tests without being asked for sudo password

This commit makes it possible to run the scripts/ct/run.sh script
without being asked for sudo password if one instead wants to use the
run docker container with root user trick to reset owner of files.

One simply has to set the environment variable
EMQX_TEST_DO_NOT_RUN_SUDO.
This commit is contained in:
Kjell Winblad 2023-02-20 18:44:34 +01:00
parent 67acdf0888
commit 96318bda1d
1 changed files with 1 additions and 1 deletions

View File

@ -197,7 +197,7 @@ if [[ -t 1 ]]; then
fi fi
function restore_ownership { function restore_ownership {
if ! sudo chown -R "$ORIG_UID_GID" . >/dev/null 2>&1; then if [[ -n ${EMQX_TEST_DO_NOT_RUN_SUDO+x} ]] || ! sudo chown -R "$ORIG_UID_GID" . >/dev/null 2>&1; then
docker exec -i $TTY -u root:root "$ERLANG_CONTAINER" bash -c "chown -R $ORIG_UID_GID /emqx" >/dev/null 2>&1 || true docker exec -i $TTY -u root:root "$ERLANG_CONTAINER" bash -c "chown -R $ORIG_UID_GID /emqx" >/dev/null 2>&1 || true
fi fi
} }