fix(synergy): support dynamic synergyc binary path, Crostini DISPLAY fallback, and reverse SSH tunnel in fleet

This commit is contained in:
Krystof Pesek
2026-11-06 06:39:28 +01:00
parent c99ad055b2
commit 37960c5848
3 changed files with 37 additions and 7 deletions
+2 -1
View File
@@ -10,7 +10,7 @@ if ! ping -c 1 -W 2 "$PENGUIN_IP" &>/dev/null; then
exit 1
fi
echo "[provision-penguin] Updating ~/bin and identity on penguin..."
echo "[provision-penguin] Updating ~/bin, identity, and SuperCollider on penguin..."
ssh -o ConnectTimeout=5 "kof@$PENGUIN_IP" '
git -C ~/bin pull origin main
sudo bash -c "cat << CONF > /etc/fleet_id
@@ -26,5 +26,6 @@ grep -q "bin-env" ~/.bashrc 2>/dev/null || echo "[ -f \"\$HOME/bin/bin-env\" ] &
grep -q "bin-env" ~/.zshrc 2>/dev/null || echo "[ -f \"\$HOME/bin/bin-env\" ] && source \"\$HOME/bin/bin-env\"" >> ~/.zshrc
~/bin/fleet-id
~/bin/setup-sc-node
'
echo "[provision-penguin] Complete."
+22 -3
View File
@@ -24,18 +24,37 @@ find_active_server() {
return 1
}
# Ensure DISPLAY is set for graphical/XWayland environments (e.g. Crostini or systemd user services)
export DISPLAY="${DISPLAY:-:0}"
# Locate synergyc binary across standard paths
SYNERGYC="$(command -v synergyc 2>/dev/null || true)"
if [ -z "$SYNERGYC" ]; then
for candidate in "/usr/local/bin/synergyc" "/usr/bin/synergyc" "$HOME/.local/bin/synergyc"; do
if [ -x "$candidate" ]; then
SYNERGYC="$candidate"
break
fi
done
fi
if [ -z "$SYNERGYC" ]; then
echo "[synergy-connect] Error: synergyc binary not found in PATH or standard locations." >&2
exit 1
fi
# Determine crypto flag based on synergyc build (note: synergyc --help exits with code 3)
CRYPTO_FLAG=""
if (/usr/local/bin/synergyc --help 2>&1 || true) | grep -q -- '--disable-crypto'; then
if ("$SYNERGYC" --help 2>&1 || true) | grep -q -- '--disable-crypto'; then
CRYPTO_FLAG="--disable-crypto"
fi
echo "[synergy-connect] Starting dynamic Synergy client for '$CLIENT_NAME'..."
echo "[synergy-connect] Starting dynamic Synergy client for '$CLIENT_NAME' using $SYNERGYC..."
while true; do
if ACTIVE_SERVER=$(find_active_server); then
echo "[synergy-connect] Found active server at $ACTIVE_SERVER. Connecting..."
/usr/local/bin/synergyc -f $CRYPTO_FLAG --name "$CLIENT_NAME" "$ACTIVE_SERVER" || true
"$SYNERGYC" -f $CRYPTO_FLAG --name "$CLIENT_NAME" "$ACTIVE_SERVER" || true
echo "[synergy-connect] Synergy client exited or disconnected. Probing again in 2s..."
else
echo "[synergy-connect] No reachable t520 server on Ethernet/WiFi/VPN. Retrying in 3s..."
+13 -3
View File
@@ -4,6 +4,16 @@ set -euo pipefail
cmd="${1:-status}"
ssh_penguin() {
local remote_cmd="$1"
if ssh -o ConnectTimeout=2 kof@192.168.1.105 "$remote_cmd" 2>/dev/null; then
return 0
elif ssh -o ConnectTimeout=2 -p 2205 kof@boxC "$remote_cmd" 2>/dev/null; then
return 0
fi
return 1
}
case "$cmd" in
start)
echo "== Starting Synergy Server on t520 (Center) =="
@@ -17,7 +27,7 @@ case "$cmd" in
ssh -o ConnectTimeout=3 boxC "systemctl --user start synergy-client" 2>/dev/null || echo "Warning: Could not start on boxC"
echo "== Starting Synergy Client on penguin (Left-Bottom) =="
ssh -o ConnectTimeout=3 kof@192.168.1.105 "systemctl --user start synergy-client" 2>/dev/null || echo "Notice: penguin is offline / sleep"
ssh_penguin "systemctl --user start synergy-client" || echo "Notice: penguin is offline / sleep or SSH port not forwarded"
echo ""
"$0" status
@@ -28,7 +38,7 @@ case "$cmd" in
systemctl --user stop synergy-server 2>/dev/null || true
ssh -o ConnectTimeout=3 bazina "systemctl --user stop synergy-client" 2>/dev/null || true
ssh -o ConnectTimeout=3 boxC "systemctl --user stop synergy-client" 2>/dev/null || true
ssh -o ConnectTimeout=3 kof@192.168.1.105 "systemctl --user stop synergy-client" 2>/dev/null || true
ssh_penguin "systemctl --user stop synergy-client" 2>/dev/null || true
echo "All Synergy services stopped."
;;
@@ -47,7 +57,7 @@ case "$cmd" in
ssh -o ConnectTimeout=2 bazina "systemctl --user is-active synergy-client 2>/dev/null" || echo "unreachable"
echo -n "penguin (Client / Left-Bottom): "
ssh -o ConnectTimeout=2 kof@192.168.1.105 "systemctl --user is-active synergy-client 2>/dev/null" || echo "offline"
ssh_penguin "systemctl --user is-active synergy-client 2>/dev/null" || echo "offline / SSH closed"
echo -n "boxC (Client / Right): "
ssh -o ConnectTimeout=2 boxC "systemctl --user is-active synergy-client 2>/dev/null" || echo "unreachable"