Files
docker-steam-headless/overlay/etc/cont-init.d/10-setup_user.sh
Josh.5 7614e503a7 Launch Xorg server direct from supervisor rather than a script
- Remove launcher for X11 and just call it from
- Improvements to the '/tmp/.X11-unix' directory
    - Move lockfile clearing to init script rather than launcher
    - Configure the 'XDG_RUNTIME_DIR' to something that is easily shared between containers
- Ensure all logs in home directory are readable
- Log Xorg service in home directory so they are more easily accessable to users
2022-10-04 17:36:40 +13:00

64 lines
1.9 KiB
Bash

PUID=${PUID:-99}
PGID=${PGID:-100}
UMASK=${UMASK:-000}
USER_PASSWORD=${USER_PASSWORD:-password}
echo "**** Configure default user ****"
echo "Setting run user uid=${PUID}(${USER}) gid=${PGID}(${USER})"
usermod -o -u "${PUID}" ${USER}
groupmod -o -g "${PGID}" ${USER}
echo "Adding run user to video, audio, input and pulse groups"
usermod -a -G video,audio,input,pulse ${USER}
echo "Adding run user to render group (for HW accelerated encoding)"
render_guid=$(stat -c "%g" /dev/dri/render* | tail -n 1)
if [[ ! -z ${render_guid} ]]; then
render_group=$(getent group "${render_guid}" | cut -d: -f1)
if [[ -z ${render_group} ]]; then
groupadd -g "${render_guid}" "videorender"
render_group="videorender"
fi
usermod -a -G ${render_group} ${USER}
fi
echo "Setting umask to ${UMASK}";
umask ${UMASK}
# Configure the 'XDG_RUNTIME_DIR' to something that is easily shared between containers
export XDG_RUNTIME_DIR=/tmp/.X11-unix/run
# export XDG_RUNTIME_DIR=/run/user/${PUID}
echo "Create the user XDG_RUNTIME_DIR path '${XDG_RUNTIME_DIR}'"
mkdir -p ${XDG_RUNTIME_DIR}
chown -R ${PUID}:${PGID} ${XDG_RUNTIME_DIR}
export XDG_DATA_DIRS="${XDG_DATA_DIRS}:/var/lib/flatpak/exports/share:/home/${USER}/.local/share/flatpak/exports/share"
# Setup home directory and permissions
echo "Adding default home directory template"
mkdir -p ${USER_HOME}
chown -R ${PUID}:${PGID} /etc/home_directory_template
rsync -aq --ignore-existing /etc/home_directory_template/ ${USER_HOME}/
chmod +x /usr/bin/start-desktop.sh
# Setup services log path
echo "Setting ownership of all log files in '${USER_HOME}/.cache/log'"
mkdir -p "${USER_HOME}/.cache/log"
chown -R ${PUID}:${PGID} "${USER_HOME}/.cache/log"
# Set the root and user password
echo "Setting root password"
echo "root:${USER_PASSWORD}" | chpasswd
echo "Setting user password"
echo "${USER}:${USER_PASSWORD}" | chpasswd
echo "DONE"