Files
NanoKVM-MIRROR/docker/entrypoint
2026-07-27 10:28:46 +08:00

31 lines
603 B
Bash
Executable File

#!/bin/sh
set -e
set -u
: "${UID:=0}"
: "${GID:=${UID}}"
if [ "$#" = 0 ]
then set -- "$(command -v bash 2>/dev/null || command -v sh)" -l
fi
if [ "$UID" != 0 ]
then
current_uid="$(id -u "$DOCKER_USER")"
current_gid="$(id -g "$DOCKER_USER")"
if [ "$current_uid" != "$UID" ]; then
usermod -u "$UID" "$DOCKER_USER"
fi
if [ "$current_gid" != "$GID" ]; then
groupmod -g "$GID" "$DOCKER_USER" 2>/dev/null ||
usermod -a -G "$GID" "$DOCKER_USER"
fi
set -- gosu "${UID}:${GID}" "${@}"
fi
exec "$@"