| 1 | #!/bin/sh |
| 2 | # Join the container's desktop session, then run the remote agent. |
| 3 | # |
| 4 | # `docker exec` starts with a fresh environment: it does not inherit the |
| 5 | # DISPLAY export or the dbus-run-session address the entrypoint created, and |
| 6 | # without the same session bus an exec'd agent cannot see the accessibility |
| 7 | # tree of apps already on the display. The entrypoint writes both to |
| 8 | # /tmp/cu-session.env; source it, then hand off. |
| 9 | set -eu |
| 10 | |
| 11 | ENV_FILE=/tmp/cu-session.env |
| 12 | if [ -f "$ENV_FILE" ]; then |
| 13 | # Sourced assignments are not exported by default; allexport marks them so |
| 14 | # the agent process (and the backend tools it runs) inherit display and bus. |
| 15 | set -a |
| 16 | # shellcheck disable=SC1090 |
| 17 | . "$ENV_FILE" |
| 18 | set +a |
| 19 | else |
| 20 | export DISPLAY="${DISPLAY:-:0}" |
| 21 | fi |
| 22 | |
| 23 | exec node /app/agent.mjs "$@" |
| 24 |