mirror of
https://github.com/sipeed/NanoKVM.git
synced 2026-09-11 09:02:05 -05:00
31 lines
603 B
Bash
Executable File
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 "$@"
|