mirror of
https://github.com/home-assistant/operating-system.git
synced 2025-04-19 14:47:15 +00:00

In case a group with the same id as used outside the container already exists, do not create a group inside the container. It seems that GitHub Action runners started to use primary group id 999 which is the default group id used by the Docker daemon.
33 lines
805 B
Bash
Executable File
33 lines
805 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
USER="root"
|
|
|
|
# Run dockerd
|
|
dockerd -s vfs &> /dev/null &
|
|
|
|
|
|
# Setup local group, if not existing
|
|
if [ "${BUILDER_GID:-0}" -ne 0 ] && ! getent group "${BUILDER_GID:-0}"; then
|
|
groupadd -g "${BUILDER_GID}" builder
|
|
fi
|
|
|
|
# Setup local user
|
|
if [ "${BUILDER_UID:-0}" -ne 0 ]; then
|
|
useradd -m -u "${BUILDER_UID}" -g "${BUILDER_GID}" -G docker,sudo builder
|
|
echo "builder ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
|
|
# Make sure cache is accessible by builder
|
|
chown "${BUILDER_UID}:${BUILDER_GID}" /cache
|
|
# Make sure output is accessible by builder (if anonymous volume is used)
|
|
chown "${BUILDER_UID}:${BUILDER_GID}" /build/output || true
|
|
USER="builder"
|
|
fi
|
|
|
|
if CMD="$(command -v "$1")"; then
|
|
shift
|
|
sudo -H -u ${USER} "$CMD" "$@"
|
|
else
|
|
echo "Command not found: $1"
|
|
exit 1
|
|
fi
|