#!/bin/bash # Wire the host-mounted LTspice binaries into the writable LTSPICE_DIR (which # holds the Wine prefix baked at image build), start a virtual display for # Wine, then hand off to the CMD. set -e src=/opt/ltspice-src dst=${LTSPICE_DIR:-/opt/ltspice} # The LTspice install is mounted read-only from the host; symlink the three # things mcltspice's config references (exe, lib, examples) next to the prefix. if [ -d "$src" ]; then for item in LTspice.exe lib examples; do if [ -e "$src/$item" ]; then ln -sfn "$src/$item" "$dst/$item" fi done fi # LTspice opens an X connection even in batch (-b) mode, so give Wine a # headless display. Clear any stale lock first -- the build-time Xvfb on the # same display can leave /tmp/.X99-lock baked into the image, which would make # a naive "already running?" check skip startup (one container = one Xvfb). if [ -n "$DISPLAY" ]; then rm -f "/tmp/.X${DISPLAY#:}-lock" Xvfb "$DISPLAY" -screen 0 1024x768x16 -nolisten tcp >/tmp/xvfb.log 2>&1 & # Give the server a moment to come up before the app can ask for it. for _ in 1 2 3 4 5 6 7 8 9 10; do [ -e "/tmp/.X11-unix/X${DISPLAY#:}" ] && break sleep 0.3 done fi exec "$@"