2017-04-08 04:43:40 -04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
|
2017-05-04 03:48:13 -04:00
|
|
|
# If command starts with an option, prepend minio.
|
2017-04-08 04:43:40 -04:00
|
|
|
if [ "${1}" != "minio" ]; then
|
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
set -- minio "$@"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-07-17 14:20:55 -04:00
|
|
|
# su-exec to requested user, if service cannot run exec will fail.
|
2019-06-10 10:57:42 -04:00
|
|
|
docker_switch_user() {
|
2021-07-14 19:55:59 -04:00
|
|
|
if [ -n "${MINIO_USERNAME}" ] && [ -n "${MINIO_GROUPNAME}" ]; then
|
|
|
|
if [ -n "${MINIO_UID}" ] && [ -n "${MINIO_GID}" ]; then
|
2020-12-08 14:14:06 -05:00
|
|
|
groupadd -g "$MINIO_GID" "$MINIO_GROUPNAME" && \
|
|
|
|
useradd -u "$MINIO_UID" -g "$MINIO_GROUPNAME" "$MINIO_USERNAME"
|
|
|
|
else
|
|
|
|
groupadd "$MINIO_GROUPNAME" && \
|
|
|
|
useradd -g "$MINIO_GROUPNAME" "$MINIO_USERNAME"
|
|
|
|
fi
|
2021-07-14 19:55:59 -04:00
|
|
|
exec setpriv --reuid="${MINIO_USERNAME}" \
|
|
|
|
--regid="${MINIO_GROUPNAME}" --keep-groups "$@"
|
2019-07-17 14:20:55 -04:00
|
|
|
else
|
|
|
|
exec "$@"
|
2019-06-12 15:16:21 -04:00
|
|
|
fi
|
2017-04-08 04:43:40 -04:00
|
|
|
}
|
|
|
|
|
2019-06-10 10:57:42 -04:00
|
|
|
## Switch to user if applicable.
|
|
|
|
docker_switch_user "$@"
|