Files
usb-crash-cart/docker-run.sh
scott e0b435b00f
All checks were successful
Docker Build and Publish / Build Docker image and publish to Gitea (push) Successful in 52s
Fix docker-run.sh to use fully-qualified image name
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-07 12:53:57 -04:00

32 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
IMAGE="git.sdgarren.com/scott/usb-crash-cart:latest"
# On Fedora with Wayland, XWayland provides X11 compatibility.
# DISPLAY is still set (e.g. :0 or :1) and /tmp/.X11-unix still exists.
if [ -z "${DISPLAY:-}" ]; then
echo "Error: DISPLAY is not set. Ensure XWayland is running (it should be by default on Fedora)."
exit 1
fi
# xhost grants the container access via hostname-based access control,
# bypassing the need to pass the raw cookie in some setups.
xhost +local:docker 2>/dev/null || echo "Warning: xhost failed — display access may not work"
# Under XWayland, X11 auth is cookie-based (XAUTHORITY file).
# Pass it into the container so the app can authenticate with XWayland.
XAUTH_ARGS=()
if [ -n "${XAUTHORITY:-}" ] && [ -f "${XAUTHORITY}" ]; then
XAUTH_ARGS=(-e XAUTHORITY="${XAUTHORITY}" -v "${XAUTHORITY}:${XAUTHORITY}:ro")
fi
# Pass all USB bus devices so the app can find the crash cart adapter.
# The udev rules (install via install-udev-rules.sh) set permissions on the host.
docker run --rm \
-e DISPLAY="${DISPLAY}" \
"${XAUTH_ARGS[@]}" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--device /dev/bus/usb \
"${IMAGE}" "$@"