-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
executable file
·32 lines (26 loc) · 1.24 KB
/
docker-entrypoint.sh
File metadata and controls
executable file
·32 lines (26 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
set -euo pipefail
# Allow runtime override of steam user UID/GID via PUID/PGID env vars.
# If they differ from current numeric IDs, we modify /etc/passwd & /etc/group accordingly
# before executing steamcmd. This requires the container to start as root.
CURRENT_UID="$(id -u steam)"
CURRENT_GID="$(id -g steam)"
DESIRED_UID="${PUID:-$CURRENT_UID}"
DESIRED_GID="${PGID:-$CURRENT_GID}"
if [[ "${DESIRED_GID}" != "${CURRENT_GID}" ]]; then
echo "Updating steam group GID: ${CURRENT_GID} -> ${DESIRED_GID}" >&2
groupmod -o -g "${DESIRED_GID}" steam
# Fix any files owned by old GID inside home (best effort)
find /home/steam -xdev -group "${CURRENT_GID}" -exec chgrp -h "${DESIRED_GID}" {} + || true
fi
if [[ "${DESIRED_UID}" != "${CURRENT_UID}" ]]; then
echo "Updating steam user UID: ${CURRENT_UID} -> ${DESIRED_UID}" >&2
usermod -o -u "${DESIRED_UID}" steam
find /home/steam -xdev -user "${CURRENT_UID}" -exec chown -h "${DESIRED_UID}" {} + || true
fi
# Ensure ownership of Steam data root (non-recursive check first, then minimal fix if needed)
if [[ ! -w /home/steam ]]; then
echo "Warning: /home/steam not writable after UID/GID adjustment" >&2
fi
# Drop to steam user and run steamcmd
exec gosu steam:steam steamcmd "$@"