Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
NTR - Add e2e volumes to check permissions directories
Browse files Browse the repository at this point in the history
Refactor check_permissions.sh to easily add new directories and
check general accessibility
  • Loading branch information
pweyck committed Jan 29, 2020
1 parent 9fd908c commit 8507b88
Showing 1 changed file with 32 additions and 14 deletions.
46 changes: 32 additions & 14 deletions dev-ops/docker/scripts/check_permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,39 @@
# create directories if they don't exists with user privileges.
# otherwise docker might create them with root privileges

composer="$HOME/.composer"
npm="$HOME/.npm"
DIRS="$HOME/.composer"
DIRS="$DIRS $HOME/.npm"
DIRS="$DIRS $PWD/vendor/shopware/platform/src/Administration/Resources/app/administration/test/e2e"
DIRS="$DIRS $PWD/vendor/shopware/platform/src/Storefront/Resources/app/storefront/test/e2e"

mkdir -p $composer
mkdir -p $npm
for dir in $DIRS; do
mkdir -p $dir || true
done

err_msg="Error: The owner of $composer and/or $npm is root. This can cause problems with your docker setup.
Please change the owner/group of these folders."
if [[ "$OSTYPE" == "darwin"* ]]; then
for dir in $DIRS; do
(cd "$dir") || {
echo "$dir is not accessible"
exit 1
}

if [[ $(stat -f '%Su' "$dir") == 'root' ]]; then
err_msg="Error: The owner of $dir is root. This can cause problems with your docker setup. Please change the owner/group of these folders."
echo $err_msg;
exit 1
fi
done
elif [[ "$OSTYPE" == "linux"* ]]; then
for dir in $DIRS; do
(cd "$dir") || {
echo "$dir is not accessible"
exit 1
}

if [[ "$OSTYPE" == "darwin"* && $(stat -f '%Su' "$composer") != 'root' && $(stat -f '%Su' "$npm") != 'root' ]]; then
exit
elif [[ "$OSTYPE" == "linux"* && $(stat -c '%U' "$composer") != 'root' && $(stat -c '%U' "$npm") != 'root' ]]; then
exit
fi;

echo "$err_msg";
exit 1
if [[ $(stat -c '%U' "$dir") == 'root' ]]; then
err_msg="Error: The owner of $dir is root. This can cause problems with your docker setup. Please change the owner/group of these folders."
echo $err_msg;
exit 1
fi
done
fi

0 comments on commit 8507b88

Please sign in to comment.