Skip to content

Commit

Permalink
Move the NEED_SUDO check at the proper place
Browse files Browse the repository at this point in the history
  • Loading branch information
a13xp0p0v committed Sep 29, 2024
1 parent 14ab02e commit 566cbb3
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions build_containers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,19 @@ show_help() {
echo "the format is incorrect."
}

groups | grep docker > /dev/null
NEED_SUDO=$?

if [ $NEED_SUDO -eq 1 ]; then
echo "Hey, we gonna use sudo for running docker"
SUDO_CMD="sudo"
else
echo "Hey, you are in docker group, sudo is not needed"
SUDO_CMD=""
fi

set -e

# Check if the user has provided an argument
if [ $# -ne 1 ]; then
echo "Building all gcc and clang version containers"
Expand Down Expand Up @@ -210,19 +223,6 @@ else
exit -1
fi

groups | grep docker > /dev/null
NEED_SUDO=$?

if [ $NEED_SUDO -eq 1 ]; then
echo "Hey, we gonna use sudo for running docker"
SUDO_CMD="sudo"
else
echo "Hey, you are in docker group, sudo is not needed"
SUDO_CMD=""
fi

set -e

# Check and handle GCC_VERSION
if [ -n "$GCC_VERSION" ]; then
build_gcc_$GCC_VERSION
Expand Down

0 comments on commit 566cbb3

Please sign in to comment.