Fix bug preventing input after the first startup of the container
Xorg was starting before udev could finish the monitor command. This prevented the X server from having access to the input devices. For some reason, any subsequent starts would be fine. Adding a small delay to the X server start and triggering a request for device events from the kernel after a delay seems to fix this issue.
This commit is contained in:
@@ -42,3 +42,5 @@ if [[ -e /dev/uinput ]]; then
|
|||||||
echo "**** Ensure the default user has permission to r/w on input devices ****";
|
echo "**** Ensure the default user has permission to r/w on input devices ****";
|
||||||
chmod 0666 /dev/uinput
|
chmod 0666 /dev/uinput
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "DONE"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
# Fech NVIDIA GPU device (if one exists)
|
# Fech NVIDIA GPU device (if one exists)
|
||||||
if [ "$NVIDIA_VISIBLE_DEVICES" == "all" ]; then
|
if [ "${NVIDIA_VISIBLE_DEVICES:-}" == "all" ]; then
|
||||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
||||||
elif [ -z "$NVIDIA_VISIBLE_DEVICES" ]; then
|
elif [ -z "${NVIDIA_VISIBLE_DEVICES:-}" ]; then
|
||||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
||||||
else
|
else
|
||||||
export gpu_select=$(nvidia-smi --format=csv --id=$(echo "$NVIDIA_VISIBLE_DEVICES" | cut -d ',' -f1) --query-gpu=uuid | sed -n 2p)
|
export gpu_select=$(nvidia-smi --format=csv --id=$(echo "$NVIDIA_VISIBLE_DEVICES" | cut -d ',' -f1) --query-gpu=uuid | sed -n 2p)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
# Fech NVIDIA GPU device (if one exists)
|
# Fech NVIDIA GPU device (if one exists)
|
||||||
if [ "$NVIDIA_VISIBLE_DEVICES" == "all" ]; then
|
if [ "${NVIDIA_VISIBLE_DEVICES:-}" == "all" ]; then
|
||||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
||||||
elif [ -z "$NVIDIA_VISIBLE_DEVICES" ]; then
|
elif [ -z "${NVIDIA_VISIBLE_DEVICES:-}" ]; then
|
||||||
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
export gpu_select=$(nvidia-smi --format=csv --query-gpu=uuid 2> /dev/null | sed -n 2p)
|
||||||
else
|
else
|
||||||
export gpu_select=$(nvidia-smi --format=csv --id=$(echo "$NVIDIA_VISIBLE_DEVICES" | cut -d ',' -f1) --query-gpu=uuid | sed -n 2p)
|
export gpu_select=$(nvidia-smi --format=csv --id=$(echo "$NVIDIA_VISIBLE_DEVICES" | cut -d ',' -f1) --query-gpu=uuid | sed -n 2p)
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ priority=30
|
|||||||
autostart=false
|
autostart=false
|
||||||
autorestart=true
|
autorestart=true
|
||||||
user=%(ENV_USER)s
|
user=%(ENV_USER)s
|
||||||
command=/usr/bin/x11vnc -display %(ENV_DISPLAY)s -rfbport %(ENV_PORT_VNC)s -shared -forever
|
command=/usr/bin/start-x11vnc.sh
|
||||||
|
environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s",DISPLAY="%(ENV_DISPLAY)s",PORT_VNC="%(ENV_PORT_VNC)s"
|
||||||
stopsignal=INT
|
stopsignal=INT
|
||||||
stdout_logfile=/home/%(ENV_USER)s/.cache/log/x11vnc.log
|
stdout_logfile=/home/%(ENV_USER)s/.cache/log/x11vnc.log
|
||||||
stdout_logfile_maxbytes=10MB
|
stdout_logfile_maxbytes=10MB
|
||||||
@@ -18,7 +19,6 @@ priority=30
|
|||||||
autostart=false
|
autostart=false
|
||||||
autorestart=true
|
autorestart=true
|
||||||
user=%(ENV_USER)s
|
user=%(ENV_USER)s
|
||||||
# /opt/noVNC/utils/launch.sh --vnc localhost:${PORT_VNC} --listen ${PORT_NOVNC_SERVICE}
|
|
||||||
command=/opt/noVNC/utils/launch.sh --vnc localhost:%(ENV_PORT_VNC)s --listen %(ENV_PORT_NOVNC_SERVICE)s
|
command=/opt/noVNC/utils/launch.sh --vnc localhost:%(ENV_PORT_VNC)s --listen %(ENV_PORT_NOVNC_SERVICE)s
|
||||||
environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s"
|
environment=HOME="/home/%(ENV_USER)s",USER="%(ENV_USER)s"
|
||||||
stopsignal=INT
|
stopsignal=INT
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ priority=20
|
|||||||
autostart=false
|
autostart=false
|
||||||
autorestart=true
|
autorestart=true
|
||||||
user=root
|
user=root
|
||||||
command=/usr/bin/Xorg -ac -noreset -novtswitch -sharevts -dpi "%(ENV_DISPLAY_DPI)s" +extension "GLX" +extension "RANDR" +extension "RENDER" vt7 "%(ENV_DISPLAY)s"
|
command=/usr/bin/start-xorg.sh
|
||||||
environment=DISPLAY="%(ENV_DISPLAY)s",DISPLAY_DPI="%(ENV_DISPLAY_DPI)s",XDG_RUNTIME_DIR="%(ENV_XDG_RUNTIME_DIR)s"
|
environment=DISPLAY="%(ENV_DISPLAY)s",DISPLAY_DPI="%(ENV_DISPLAY_DPI)s",XDG_RUNTIME_DIR="%(ENV_XDG_RUNTIME_DIR)s"
|
||||||
stopsignal=INT
|
stopsignal=INT
|
||||||
stdout_logfile=/home/%(ENV_USER)s/.cache/log/xorg.log
|
stdout_logfile=/home/%(ENV_USER)s/.cache/log/xorg.log
|
||||||
|
|||||||
25
overlay/usr/bin/common-functions.sh
Executable file
25
overlay/usr/bin/common-functions.sh
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
###
|
||||||
|
# File: common-functions.sh
|
||||||
|
# Project: bin
|
||||||
|
# File Created: Tuesday, 6th October 2022 9:30:00 pm
|
||||||
|
# Author: Josh.5 (jsunnex@gmail.com)
|
||||||
|
# -----
|
||||||
|
# Last Modified: Tuesday, 6th October 2022 9:30:00 pm
|
||||||
|
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||||
|
###
|
||||||
|
|
||||||
|
wait_for_x() {
|
||||||
|
# Wait for X server to start
|
||||||
|
# (Credit: https://gist.github.com/tullmann/476cc71169295d5c3fe6)
|
||||||
|
MAX=60 # About 30 seconds
|
||||||
|
CT=0
|
||||||
|
while ! xdpyinfo >/dev/null 2>&1; do
|
||||||
|
sleep 0.50s
|
||||||
|
CT=$(( CT + 1 ))
|
||||||
|
if [ "$CT" -ge "$MAX" ]; then
|
||||||
|
LOG "FATAL: $0: Gave up waiting for X server $DISPLAY"
|
||||||
|
exit 11
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
@@ -8,15 +8,14 @@
|
|||||||
# Last Modified: Wednesday, 26th January 2022 5:38:23 pm
|
# Last Modified: Wednesday, 26th January 2022 5:38:23 pm
|
||||||
# Modified By: Console and webGui login account (jsunnex@gmail.com)
|
# Modified By: Console and webGui login account (jsunnex@gmail.com)
|
||||||
###
|
###
|
||||||
#
|
|
||||||
# I made this wrapper script so that I could easily try a range of desktop environments
|
source /usr/bin/common-functions.sh
|
||||||
#
|
|
||||||
|
|
||||||
# CATCH TERM SIGNAL:
|
# CATCH TERM SIGNAL:
|
||||||
_term() {
|
_term() {
|
||||||
kill -TERM "$desktop_pid" 2>/dev/null
|
kill -TERM "$desktop_pid" 2>/dev/null
|
||||||
}
|
}
|
||||||
trap _term SIGTERM
|
trap _term SIGTERM SIGINT
|
||||||
|
|
||||||
|
|
||||||
# CONFIGURE:
|
# CONFIGURE:
|
||||||
@@ -31,6 +30,8 @@ ln -sf /usr/share/backgrounds/steam.jpg /etc/alternatives/desktop-background
|
|||||||
|
|
||||||
|
|
||||||
# EXECUTE PROCESS:
|
# EXECUTE PROCESS:
|
||||||
|
# Wait for the X server to start
|
||||||
|
wait_for_x
|
||||||
# Run the desktop environment in order of priority
|
# Run the desktop environment in order of priority
|
||||||
if [[ -e /usr/bin/cinnamon-session ]]; then
|
if [[ -e /usr/bin/cinnamon-session ]]; then
|
||||||
/usr/bin/cinnamon-session --display=${DISPLAY} &
|
/usr/bin/cinnamon-session --display=${DISPLAY} &
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
_term() {
|
_term() {
|
||||||
kill -TERM "$pulseaudio_pid" 2>/dev/null
|
kill -TERM "$pulseaudio_pid" 2>/dev/null
|
||||||
}
|
}
|
||||||
trap _term SIGTERM
|
trap _term SIGTERM SIGINT
|
||||||
|
|
||||||
|
|
||||||
# EXECUTE PROCESS:
|
# EXECUTE PROCESS:
|
||||||
|
|||||||
@@ -9,11 +9,13 @@
|
|||||||
# Modified By: Josh.5 (jsunnex@gmail.com)
|
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||||
###
|
###
|
||||||
|
|
||||||
|
source /usr/bin/common-functions.sh
|
||||||
|
|
||||||
# CATCH TERM SIGNAL:
|
# CATCH TERM SIGNAL:
|
||||||
_term() {
|
_term() {
|
||||||
kill -TERM "$sunshine_pid" 2>/dev/null
|
kill -TERM "$sunshine_pid" 2>/dev/null
|
||||||
}
|
}
|
||||||
trap _term SIGTERM
|
trap _term SIGTERM SIGINT
|
||||||
|
|
||||||
|
|
||||||
# CONFIGURE:
|
# CONFIGURE:
|
||||||
@@ -25,18 +27,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
# EXECUTE PROCESS:
|
# EXECUTE PROCESS:
|
||||||
# Wait for X server to start
|
# Wait for the X server to start
|
||||||
# (Credit: https://gist.github.com/tullmann/476cc71169295d5c3fe6)
|
wait_for_x
|
||||||
MAX=60 # About 30 seconds
|
# Start the sunshine server
|
||||||
CT=0
|
|
||||||
while ! xdpyinfo >/dev/null 2>&1; do
|
|
||||||
sleep 0.50s
|
|
||||||
CT=$(( CT + 1 ))
|
|
||||||
if [ "$CT" -ge "$MAX" ]; then
|
|
||||||
LOG "FATAL: $0: Gave up waiting for X server $DISPLAY"
|
|
||||||
exit 11
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
sunshine min_log_level=info /home/${USER}/sunshine/sunshine.conf &
|
sunshine min_log_level=info /home/${USER}/sunshine/sunshine.conf &
|
||||||
sunshine_pid=$!
|
sunshine_pid=$!
|
||||||
|
|
||||||
|
|||||||
@@ -12,30 +12,28 @@
|
|||||||
# CATCH TERM SIGNAL:
|
# CATCH TERM SIGNAL:
|
||||||
_term() {
|
_term() {
|
||||||
kill -TERM "$monitor_pid" 2>/dev/null
|
kill -TERM "$monitor_pid" 2>/dev/null
|
||||||
kill -TERM "$trigger_pid" 2>/dev/null
|
|
||||||
kill -TERM "$udevd_pid" 2>/dev/null
|
|
||||||
}
|
}
|
||||||
trap _term SIGTERM
|
trap _term SIGTERM SIGINT
|
||||||
|
|
||||||
|
|
||||||
# EXECUTE PROCESS:
|
# EXECUTE PROCESS:
|
||||||
|
# Remove lockfile
|
||||||
|
rm -f /tmp/.udev-started
|
||||||
# Start udev
|
# Start udev
|
||||||
# Source: https://github.com/balena-io-playground/balena-base-images/
|
|
||||||
if command -v udevd &>/dev/null; then
|
if command -v udevd &>/dev/null; then
|
||||||
unshare --net udevd --daemon &>/dev/null
|
unshare --net udevd --daemon &>/dev/null
|
||||||
udevd_pid=$!
|
|
||||||
else
|
else
|
||||||
unshare --net /lib/systemd/systemd-udevd --daemon &>/dev/null
|
unshare --net /lib/systemd/systemd-udevd --daemon &>/dev/null
|
||||||
udevd_pid=$!
|
|
||||||
fi
|
fi
|
||||||
udevadm trigger &>/dev/null
|
|
||||||
trigger_pid=$!
|
|
||||||
# Monitor kernel uevents
|
# Monitor kernel uevents
|
||||||
udevadm monitor &
|
udevadm monitor &
|
||||||
monitor_pid=$!
|
monitor_pid=$!
|
||||||
|
# Touch lockfile
|
||||||
|
sleep 1
|
||||||
|
touch /tmp/.udev-started
|
||||||
|
# Wait for 10 seconds, then request device events from the kernel
|
||||||
|
sleep 10
|
||||||
|
udevadm trigger
|
||||||
|
|
||||||
# WAIT FOR CHILD PROCESS:
|
# WAIT FOR CHILD PROCESS:
|
||||||
wait "$monitor_pid"
|
wait "$monitor_pid"
|
||||||
wait "$trigger_pid"
|
|
||||||
wait "$udevd_pid"
|
|
||||||
|
|||||||
30
overlay/usr/bin/start-x11vnc.sh
Executable file
30
overlay/usr/bin/start-x11vnc.sh
Executable file
@@ -0,0 +1,30 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
###
|
||||||
|
# File: start-x11vnc.sh
|
||||||
|
# Project: bin
|
||||||
|
# File Created: Tuesday, 6th October 2022 9:30:00 pm
|
||||||
|
# Author: Josh.5 (jsunnex@gmail.com)
|
||||||
|
# -----
|
||||||
|
# Last Modified: Tuesday, 6th October 2022 9:30:00 pm
|
||||||
|
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||||
|
###
|
||||||
|
|
||||||
|
source /usr/bin/common-functions.sh
|
||||||
|
|
||||||
|
# CATCH TERM SIGNAL:
|
||||||
|
_term() {
|
||||||
|
kill -TERM "$x11vnc_pid" 2>/dev/null
|
||||||
|
}
|
||||||
|
trap _term SIGTERM SIGINT
|
||||||
|
|
||||||
|
|
||||||
|
# EXECUTE PROCESS:
|
||||||
|
# Wait for the X server to start
|
||||||
|
wait_for_x
|
||||||
|
# Start the x11vnc server
|
||||||
|
/usr/bin/x11vnc -display ${DISPLAY} -rfbport ${PORT_VNC} -shared -forever&
|
||||||
|
x11vnc_pid=$!
|
||||||
|
|
||||||
|
|
||||||
|
# WAIT FOR CHILD PROCESS:
|
||||||
|
wait "$x11vnc_pid"
|
||||||
37
overlay/usr/bin/start-xorg.sh
Executable file
37
overlay/usr/bin/start-xorg.sh
Executable file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/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: Friday, 6th October 2022 9:21:00 pm
|
||||||
|
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||||
|
###
|
||||||
|
|
||||||
|
# CATCH TERM SIGNAL:
|
||||||
|
_term() {
|
||||||
|
kill -TERM "$xorg_pid" 2>/dev/null
|
||||||
|
}
|
||||||
|
trap _term SIGTERM SIGINT
|
||||||
|
|
||||||
|
|
||||||
|
# EXECUTE PROCESS:
|
||||||
|
# Wait for udev
|
||||||
|
MAX=10
|
||||||
|
CT=0
|
||||||
|
while [ ! -f /tmp/.udev-started ]; do
|
||||||
|
sleep 1
|
||||||
|
CT=$(( CT + 1 ))
|
||||||
|
if [ "$CT" -ge "$MAX" ]; then
|
||||||
|
LOG "FATAL: $0: Gave up waiting for udev server to start"
|
||||||
|
exit 11
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# Run X server
|
||||||
|
/usr/bin/Xorg -ac -noreset -novtswitch -sharevts -dpi "${DISPLAY_DPI}" +extension "GLX" +extension "RANDR" +extension "RENDER" vt7 "${DISPLAY}" &
|
||||||
|
xorg_pid=$!
|
||||||
|
|
||||||
|
|
||||||
|
# WAIT FOR CHILD PROCESS:
|
||||||
|
wait "$xorg_pid"
|
||||||
Reference in New Issue
Block a user