Add EMBS remote access setup: embs.sh, README guide, VLAB docs
This commit is contained in:
99
embs.sh
Executable file
99
embs.sh
Executable file
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# embs.sh - connect to the York CS Linux server with the Vivado / Vitis GUI
|
||||
# forwarded to the XQuartz X server running on this Mac.
|
||||
#
|
||||
# Vivado and Vitis have no macOS build, so they run on csteach0.york.ac.uk and
|
||||
# their windows are drawn here by XQuartz over an X11-forwarded SSH connection.
|
||||
#
|
||||
# Usage:
|
||||
# ./embs.sh interactive shell, X11 forwarded (normal use)
|
||||
# ./embs.sh --check verify the local X server and show what would run
|
||||
# ./embs.sh 'vivado -version' run one remote command, then disconnect
|
||||
#
|
||||
# The remote host can be overridden, e.g. EMBS_HOST=csteach1.york.ac.uk ./embs.sh
|
||||
#
|
||||
# Note: this script only prepares the local X server and starts ssh. The hop
|
||||
# through the SSH gateway, and any 2FA prompt it raises, are handled by the
|
||||
# ProxyCommand already configured in ~/.ssh/config.
|
||||
|
||||
set -e
|
||||
|
||||
HOST="${EMBS_HOST:-csteach0.york.ac.uk}"
|
||||
XDPYINFO=/opt/X11/bin/xdpyinfo
|
||||
|
||||
# Return the first local X display we can actually reach, or nothing.
|
||||
working_display() {
|
||||
local d
|
||||
for d in "${DISPLAY:-}" ":0"; do
|
||||
[ -n "$d" ] || continue
|
||||
if [ -x "$XDPYINFO" ] && "$XDPYINFO" -display "$d" >/dev/null 2>&1; then
|
||||
printf '%s' "$d"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
start_xquartz() {
|
||||
if [ ! -d /Applications/Utilities/XQuartz.app ]; then
|
||||
echo "error: XQuartz is not installed." >&2
|
||||
echo " Install it with: brew install --cask xquartz" >&2
|
||||
return 1
|
||||
fi
|
||||
echo "Starting XQuartz..."
|
||||
open -a XQuartz || return 1
|
||||
local i
|
||||
for i in $(seq 1 30); do
|
||||
if "$XDPYINFO" -display :0 >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
CHECK_ONLY=no
|
||||
if [ "${1:-}" = "--check" ]; then
|
||||
CHECK_ONLY=yes
|
||||
shift
|
||||
fi
|
||||
|
||||
# --- 1. Make sure there is a usable local X server ---------------------------
|
||||
DISP="$(working_display || true)"
|
||||
if [ -z "$DISP" ] && [ "$CHECK_ONLY" = no ]; then
|
||||
if start_xquartz; then
|
||||
DISP=":0"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$DISP" ]; then
|
||||
echo "warning: no X server reachable on this Mac." >&2
|
||||
echo " XQuartz is installed but may not be running, or DISPLAY is not exported." >&2
|
||||
echo " Try: open -a XQuartz (then log out and back in once)" >&2
|
||||
echo " Vivado / Vitis windows will NOT appear until this is fixed." >&2
|
||||
else
|
||||
export DISPLAY="$DISP"
|
||||
fi
|
||||
|
||||
# --- 2. Report and connect ---------------------------------------------------
|
||||
if [ "$CHECK_ONLY" = yes ]; then
|
||||
echo "XQuartz installed : yes"
|
||||
echo "X server reachable: ${DISP:-no}"
|
||||
echo "DISPLAY would be : ${DISP:-<unset>}"
|
||||
echo "Would run : ssh -Y -C -o ServerAliveInterval=60 $HOST"
|
||||
if [ "$#" -gt 0 ]; then
|
||||
echo "Remote command : $*"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Connecting to $HOST with DISPLAY=${DISPLAY:-<unset>} ..."
|
||||
echo "If the gateway asks for a password or Duo approval, that is the university's 2FA."
|
||||
echo
|
||||
|
||||
if [ "$#" -gt 0 ]; then
|
||||
exec ssh -Y -C -o ServerAliveInterval=60 "$HOST" "$@"
|
||||
else
|
||||
exec ssh -Y -C -o ServerAliveInterval=60 "$HOST"
|
||||
fi
|
||||
Reference in New Issue
Block a user