Skip to content

Commit 9bbba44

Browse files
authored
Check directory permission in docker-entrypoint.sh with test -w (#930)
1 parent eabf806 commit 9bbba44

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

docker-entrypoint.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22

33
set -e
44

5-
# Get UID/GID from volume dir
6-
VOLUME_UID=$(stat -c '%u' $VOLUME_DIR)
7-
VOLUME_GID=$(stat -c '%g' $VOLUME_DIR)
8-
9-
MY_UID=$(id -u)
10-
MY_GID=$(id -g)
11-
125
# Run as custom user
13-
if [ "$MY_GID" != "$VOLUME_GID" ] || [ "$MY_UID" != "$VOLUME_UID" ]; then
6+
if ! [ -w $VOLUME_DIR ]; then
7+
# Get UID/GID from volume dir
8+
VOLUME_UID=$(stat -c '%u' $VOLUME_DIR)
9+
VOLUME_GID=$(stat -c '%g' $VOLUME_DIR)
10+
1411
# create or modify user and group to match expected uid/gid
1512
groupadd --gid $VOLUME_GID archivist || groupmod -o --gid $VOLUME_GID archivist
1613
useradd -ms /bin/bash -u $VOLUME_UID -g $VOLUME_GID archivist || usermod -o -u $VOLUME_UID archivist
@@ -36,4 +33,3 @@ else
3633
# run process directly
3734
exec $@
3835
fi
39-

0 commit comments

Comments
 (0)