entrypoint
574 Bytes
#!/bin/bash
set -ex
TARGET_GROUP=redis
TARGET_USER=redis
target_home="$(getent passwd "$TARGET_USER" | cut -f 6 -d :)"
if [[ $GID && $GID -ne 0 ]]; then
groupmod -g $GID "$TARGET_GROUP"
fi
if [[ $UID && $UID -ne 0 ]]; then
usermod -u $UID "$TARGET_USER"
fi
find "$target_home" \
'(' -not -user "$TARGET_USER" -a -not -group "$TARGET_GROUP" -exec chown "$TARGET_USER:$TARGET_GROUP" '{}' + ')' -o \
'(' -not -user "$TARGET_USER" -exec chown "$TARGET_USER" '{}' + ')' -o \
'(' -not -group "$TARGET_GROUP" -exec chgrp "$TARGET_GROUP" '{}' + ')' -o \
-true
exec "$@"