mirror of
https://github.com/minio/minio.git
synced 2024-12-25 22:55:54 -05:00
430669cfad
fixes #16488
30 lines
870 B
Bash
Executable File
30 lines
870 B
Bash
Executable File
#!/bin/sh
|
|
#
|
|
|
|
# If command starts with an option, prepend minio.
|
|
if [ "${1}" != "minio" ]; then
|
|
if [ -n "${1}" ]; then
|
|
set -- minio "$@"
|
|
fi
|
|
fi
|
|
|
|
# su-exec to requested user, if service cannot run exec will fail.
|
|
docker_switch_user() {
|
|
if [ -n "${MINIO_USERNAME}" ] && [ -n "${MINIO_GROUPNAME}" ]; then
|
|
if [ -n "${MINIO_UID}" ] && [ -n "${MINIO_GID}" ]; then
|
|
groupadd -f -g "$MINIO_GID" "$MINIO_GROUPNAME" && \
|
|
useradd -u "$MINIO_UID" -g "$MINIO_GROUPNAME" "$MINIO_USERNAME"
|
|
else
|
|
groupadd -f "$MINIO_GROUPNAME" && \
|
|
useradd -g "$MINIO_GROUPNAME" "$MINIO_USERNAME"
|
|
fi
|
|
exec setpriv --reuid="${MINIO_USERNAME}" \
|
|
--regid="${MINIO_GROUPNAME}" --keep-groups "$@"
|
|
else
|
|
exec "$@"
|
|
fi
|
|
}
|
|
|
|
## Switch to user if applicable.
|
|
docker_switch_user "$@"
|