From 7614e503a7e4969fa514aab8b86ee4b843d26d3d Mon Sep 17 00:00:00 2001 From: "Josh.5" Date: Sun, 2 Oct 2022 11:33:15 +0000 Subject: [PATCH] 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 --- overlay/etc/cont-init.d/10-setup_user.sh | 10 ++++++- overlay/etc/cont-init.d/70-configure_xorg.sh | 12 +++++--- overlay/etc/supervisor.d/xorg.ini | 8 +++--- overlay/usr/bin/start-xorg.sh | 30 -------------------- 4 files changed, 21 insertions(+), 39 deletions(-) delete mode 100644 overlay/usr/bin/start-xorg.sh diff --git a/overlay/etc/cont-init.d/10-setup_user.sh b/overlay/etc/cont-init.d/10-setup_user.sh index 5b2feb5..ff44e27 100644 --- a/overlay/etc/cont-init.d/10-setup_user.sh +++ b/overlay/etc/cont-init.d/10-setup_user.sh @@ -31,7 +31,9 @@ echo "Setting umask to ${UMASK}"; umask ${UMASK} -export XDG_RUNTIME_DIR=/run/user/${PUID} +# 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} @@ -46,6 +48,12 @@ 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 diff --git a/overlay/etc/cont-init.d/70-configure_xorg.sh b/overlay/etc/cont-init.d/70-configure_xorg.sh index 0660be0..77b46e4 100644 --- a/overlay/etc/cont-init.d/70-configure_xorg.sh +++ b/overlay/etc/cont-init.d/70-configure_xorg.sh @@ -47,8 +47,14 @@ function configure_x_server { fi # Ensure the X socket path exists - if [ ! -d /tmp/.X11-unix ]; then - mkdir -p /tmp/.X11-unix + mkdir -p /tmp/.X11-unix + + # Clear out old lock files + display_file=/tmp/.X11-unix/X${DISPLAY#:} + if [ -S ${display_file} ]; then + echo "Removing ${display_file} before starting" + rm -f /tmp/.X${DISPLAY#:}-lock + rm ${display_file} fi # Ensure X-windows session path is owned by root @@ -68,8 +74,6 @@ function configure_x_server { # Enable xvfb supervisord script sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/xvfb.ini fi - # Make startup script executable - chmod +x /usr/bin/start-xorg.sh } if ([ "${MODE}" != "s" ] && [ "${MODE}" != "secondary" ]); then diff --git a/overlay/etc/supervisor.d/xorg.ini b/overlay/etc/supervisor.d/xorg.ini index 4a279d7..4869f69 100644 --- a/overlay/etc/supervisor.d/xorg.ini +++ b/overlay/etc/supervisor.d/xorg.ini @@ -4,12 +4,12 @@ priority=20 autostart=false autorestart=true user=root -command=/usr/bin/start-xorg.sh -environment=DISPLAY="%(ENV_DISPLAY)s",DISPLAY_DPI="%(ENV_DISPLAY_DPI)s" +command=/usr/bin/Xorg -ac -noreset -novtswitch -sharevts -dpi "%(ENV_DISPLAY_DPI)s" +extension "GLX" +extension "RANDR" +extension "RENDER" vt7 "%(ENV_DISPLAY)s" +environment=DISPLAY="%(ENV_DISPLAY)s",DISPLAY_DPI="%(ENV_DISPLAY_DPI)s",XDG_RUNTIME_DIR="%(ENV_XDG_RUNTIME_DIR)s" stopsignal=INT -#stdout_logfile=/var/log/supervisor/xorg.log +stdout_logfile=/home/%(ENV_USER)s/.cache/log/xorg.log stdout_logfile_maxbytes=10MB stdout_logfile_backups=7 -#stderr_logfile=/var/log/supervisor/xorg.err.log +stderr_logfile=/home/%(ENV_USER)s/.cache/log/xorg.err.log stderr_logfile_maxbytes=10MB stderr_logfile_backups=7 diff --git a/overlay/usr/bin/start-xorg.sh b/overlay/usr/bin/start-xorg.sh deleted file mode 100644 index 0ac95d3..0000000 --- a/overlay/usr/bin/start-xorg.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env bash -### -# File: start-xorg.sh -# Project: bin -# File Created: Tuesday, 11th January 2022 8:28:52 pm -# Author: Josh.5 (jsunnex@gmail.com) -# ----- -# Last Modified: Monday, 24th January 2022 6:01:38 pm -# Modified By: Console and webGui login account (jsunnex@gmail.com) -### - -DISPLAY=${DISPLAY:-:55} -DISPLAY_DPI=${DPI:-:96} -XDG_RUNTIME_DIR=/run/user/$(id -u ${USER}) - - -# Clear out old lock files -display_file=/tmp/.X11-unix/X${DISPLAY#:} -if [ -S ${display_file} ]; then - LOG "Removing ${display_file} before starting" - rm -f /tmp/.X${DISPLAY#:}-lock - rm ${display_file} -fi - - -/usr/bin/Xorg -ac -noreset -novtswitch -sharevts -dpi "${DISPLAY_DPI}" +extension "GLX" +extension "RANDR" +extension "RENDER" vt7 "${DISPLAY}" -# /usr/bin/Xorg -ac -noreset -novtswitch -sharevts -dpi "${DISPLAY_DPI}" +extension "GLX" +extension "RANDR" +extension "RENDER" +extension "MIT-SHM" vt7 "${DISPLAY}" -# /usr/bin/Xorg -novtswitch -sharevts -dpi "${DISPLAY_DPI}" +extension "MIT-SHM" vt7 ${DISPLAY} -# /usr/bin/Xorg -novtswitch -sharevts -dpi "${DISPLAY_DPI}" +extension "MIT-SHM" "${DISPLAY}" -# /usr/bin/Xorg -ac -noreset +extension GLX +extension RANDR +extension RENDER vt7 "${DISPLAY}"