|
@@ -65,24 +65,35 @@ EOF
|
|
|
echo "Sunshine configuration:"
|
|
echo "Sunshine configuration:"
|
|
|
cat "${HOME}/.config/sunshine/sunshine.conf"
|
|
cat "${HOME}/.config/sunshine/sunshine.conf"
|
|
|
|
|
|
|
|
-echo "Triggering input hotplug..."
|
|
|
|
|
-udevadm trigger --subsystem-match=input
|
|
|
|
|
-
|
|
|
|
|
echo
|
|
echo
|
|
|
echo "Starting Sunshine..."
|
|
echo "Starting Sunshine..."
|
|
|
/usr/bin/sunshine &
|
|
/usr/bin/sunshine &
|
|
|
SUNSHINE_PID=$!
|
|
SUNSHINE_PID=$!
|
|
|
|
|
|
|
|
|
|
+cleanup() {
|
|
|
|
|
+ echo "Stopping Sunshine..."
|
|
|
|
|
+ kill "${SUNSHINE_PID}" 2>/dev/null || true
|
|
|
|
|
+ wait "${SUNSHINE_PID}" 2>/dev/null || true
|
|
|
|
|
+
|
|
|
|
|
+ echo "Stopping supervisor..."
|
|
|
|
|
+ kill "${SUPERVISOR_PID}" 2>/dev/null || true
|
|
|
|
|
+ wait "${SUPERVISOR_PID}" 2>/dev/null || true
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+trap cleanup EXIT TERM INT
|
|
|
|
|
+
|
|
|
|
|
+echo
|
|
|
echo "Waiting for Sunshine virtual input devices..."
|
|
echo "Waiting for Sunshine virtual input devices..."
|
|
|
|
|
|
|
|
for i in $(seq 1 30); do
|
|
for i in $(seq 1 30); do
|
|
|
- if grep -q 'Name="Mouse passthrough"' /proc/bus/input/devices; then
|
|
|
|
|
- echo "Sunshine virtual input devices detected."
|
|
|
|
|
|
|
+ if grep -q 'Name="Mouse passthrough"' /proc/bus/input/devices \
|
|
|
|
|
+ && grep -q 'Name="Keyboard passthrough"' /proc/bus/input/devices; then
|
|
|
|
|
+ echo "Sunshine virtual mouse and keyboard detected."
|
|
|
break
|
|
break
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
if ! kill -0 "${SUNSHINE_PID}" 2>/dev/null; then
|
|
if ! kill -0 "${SUNSHINE_PID}" 2>/dev/null; then
|
|
|
- echo "ERROR: Sunshine exited."
|
|
|
|
|
|
|
+ echo "ERROR: Sunshine exited before creating input devices."
|
|
|
wait "${SUNSHINE_PID}"
|
|
wait "${SUNSHINE_PID}"
|
|
|
exit $?
|
|
exit $?
|
|
|
fi
|
|
fi
|
|
@@ -90,7 +101,51 @@ for i in $(seq 1 30); do
|
|
|
sleep 1
|
|
sleep 1
|
|
|
done
|
|
done
|
|
|
|
|
|
|
|
-echo "Triggering input hotplug..."
|
|
|
|
|
-udevadm trigger --subsystem-match=input
|
|
|
|
|
|
|
+echo
|
|
|
|
|
+echo "Restarting Xorg so it picks up Sunshine virtual input devices..."
|
|
|
|
|
+
|
|
|
|
|
+supervisorctl stop entrypoint || true
|
|
|
|
|
+
|
|
|
|
|
+pkill -TERM -x Xorg || true
|
|
|
|
|
+
|
|
|
|
|
+for i in $(seq 1 20); do
|
|
|
|
|
+ if ! pgrep -x Xorg >/dev/null; then
|
|
|
|
|
+ break
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ sleep 0.5
|
|
|
|
|
+done
|
|
|
|
|
+
|
|
|
|
|
+if pgrep -x Xorg >/dev/null; then
|
|
|
|
|
+ echo "Xorg did not stop cleanly, sending SIGKILL..."
|
|
|
|
|
+ pkill -KILL -x Xorg || true
|
|
|
|
|
+ sleep 1
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+echo "Starting desktop/Xorg again..."
|
|
|
|
|
+supervisorctl start entrypoint
|
|
|
|
|
+
|
|
|
|
|
+echo "Waiting for restarted Xorg..."
|
|
|
|
|
+
|
|
|
|
|
+for i in $(seq 1 60); do
|
|
|
|
|
+ if xdpyinfo -display "${DISPLAY}" >/dev/null 2>&1; then
|
|
|
|
|
+ echo "Restarted Xorg is ready."
|
|
|
|
|
+ break
|
|
|
|
|
+ fi
|
|
|
|
|
+
|
|
|
|
|
+ sleep 1
|
|
|
|
|
+done
|
|
|
|
|
+
|
|
|
|
|
+echo
|
|
|
|
|
+echo "Checking Sunshine input devices in Xorg log..."
|
|
|
|
|
+
|
|
|
|
|
+grep -Ei \
|
|
|
|
|
+ 'Mouse passthrough|Keyboard passthrough|libinput' \
|
|
|
|
|
+ /home/ubuntu/.local/share/xorg/Xorg.20.log \
|
|
|
|
|
+ | tail -30 \
|
|
|
|
|
+ || true
|
|
|
|
|
+
|
|
|
|
|
+echo
|
|
|
|
|
+echo "Sunshine Gaming Desktop ready."
|
|
|
|
|
|
|
|
wait "${SUNSHINE_PID}"
|
|
wait "${SUNSHINE_PID}"
|