Skip to content

Check directory permission in docker-entrypoint.sh with test -w #930

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

set -e

# Get UID/GID from volume dir
VOLUME_UID=$(stat -c '%u' $VOLUME_DIR)
VOLUME_GID=$(stat -c '%g' $VOLUME_DIR)

MY_UID=$(id -u)
MY_GID=$(id -g)

# Run as custom user
if [ "$MY_GID" != "$VOLUME_GID" ] || [ "$MY_UID" != "$VOLUME_UID" ]; then
if ! [ -w $VOLUME_DIR ]; then
# Get UID/GID from volume dir
VOLUME_UID=$(stat -c '%u' $VOLUME_DIR)
VOLUME_GID=$(stat -c '%g' $VOLUME_DIR)

# create or modify user and group to match expected uid/gid
groupadd --gid $VOLUME_GID archivist || groupmod -o --gid $VOLUME_GID archivist
useradd -ms /bin/bash -u $VOLUME_UID -g $VOLUME_GID archivist || usermod -o -u $VOLUME_UID archivist
Expand All @@ -36,4 +33,3 @@ else
# run process directly
exec $@
fi