-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·53 lines (47 loc) · 2.1 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·53 lines (47 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
# Launch Open Stage Control with the spatial-control session + module.
# Run this ON THE SAME MAC AS Max/SPAT5 (10.112.10.50) so OSC stays on localhost.
#
# ./run.sh
# then browse from any device on the LAN to: http://10.112.10.50:8080
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SESSION="$HERE/session.json"
MODULE="$HERE/modules/spatial.js"
ENGINE_SEND="127.0.0.1:9000" # -> Max's [udpreceive 9000] (keep in sync with src/config.ts)
WEB_PORT="8080" # browser UI: http://<this-mac-ip>:8080
OSC_IN_PORT="9001" # OSC feedback from Max (optional)
# Resolve the Open Stage Control executable. Open Stage Control is distributed as a
# prebuilt macOS .app (not an npm global), so we look for it in /Applications.
# Override anytime with: OSC_BIN="/path/to/binary" ./run.sh
BIN="${OSC_BIN:-}"
if [ -z "$BIN" ]; then
if command -v open-stage-control >/dev/null 2>&1; then
BIN="open-stage-control"
else
# Find the app (matches "Open Stage Control.app" or "open-stage-control.app")
APP="$(ls -d /Applications/*[Ss]tage*[Cc]ontrol*.app 2>/dev/null | head -n1 || true)"
if [ -n "$APP" ] && [ -d "$APP/Contents/MacOS" ]; then
BIN="$(ls "$APP/Contents/MacOS/"* 2>/dev/null | head -n1 || true)"
fi
fi
fi
if [ -z "$BIN" ] || { ! command -v "$BIN" >/dev/null 2>&1 && [ ! -x "$BIN" ]; }; then
echo "ERROR: Open Stage Control not found." >&2
echo "Put the app in /Applications, or set OSC_BIN to its binary, e.g.:" >&2
echo ' OSC_BIN="/Applications/Open Stage Control.app/Contents/MacOS/Open Stage Control" ./run.sh' >&2
exit 1
fi
echo "Using Open Stage Control: $BIN"
# Ports below 1024 are privileged on macOS — bind will fail with EACCES unless we're root.
if [ "$WEB_PORT" -lt 1024 ] && [ "$(id -u)" -ne 0 ]; then
echo "ERROR: port ${WEB_PORT} is privileged; re-run with sudo: sudo ./run.sh" >&2
exit 1
fi
echo "Serving UI on http://0.0.0.0:${WEB_PORT} -> sending OSC to ${ENGINE_SEND}"
exec "$BIN" \
--load "$SESSION" \
--custom-module "$MODULE" \
--send "$ENGINE_SEND" \
--port "$WEB_PORT" \
--osc-port "$OSC_IN_PORT"