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
|
2023-05-26 01:07:25 -04:00
|
|
|
if [ -n "${1}" ]; then
|
|
|
|
set -- minio "$@"
|
|
|
|
fi
|
2017-04-08 04:43:40 -04:00
|
|
|
fi
|
|
|
|
|
2019-06-10 10:57:42 -04:00
|
|
|
docker_switch_user() {
|
2023-05-26 01:07:25 -04:00
|
|
|
if [ -n "${MINIO_USERNAME}" ] && [ -n "${MINIO_GROUPNAME}" ]; then
|
|
|
|
if [ -n "${MINIO_UID}" ] && [ -n "${MINIO_GID}" ]; then
|
2023-11-03 17:18:18 -04:00
|
|
|
chroot --userspec=${MINIO_UID}:${MINIO_GID} / "$@"
|
2023-05-26 01:07:25 -04:00
|
|
|
else
|
2023-11-03 17:18:18 -04:00
|
|
|
echo "${MINIO_USERNAME}:x:1000:1000:${MINIO_USERNAME}:/:/sbin/nologin" >>/etc/passwd
|
|
|
|
echo "${MINIO_GROUPNAME}:x:1000" >>/etc/group
|
|
|
|
chroot --userspec=${MINIO_USERNAME}:${MINIO_GROUPNAME} / "$@"
|
2023-05-26 01:07:25 -04:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
exec "$@"
|
|
|
|
fi
|
2017-04-08 04:43:40 -04:00
|
|
|
}
|
|
|
|
|
2023-11-03 17:18:18 -04:00
|
|
|
## DEPRECATED and unsupported - switch to user if applicable.
|
2019-06-10 10:57:42 -04:00
|
|
|
docker_switch_user "$@"
|