fix(synergy): support dynamic synergyc binary path, Crostini DISPLAY fallback, and reverse SSH tunnel in fleet
This commit is contained in:
+2
-1
@@ -10,7 +10,7 @@ if ! ping -c 1 -W 2 "$PENGUIN_IP" &>/dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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" '
|
ssh -o ConnectTimeout=5 "kof@$PENGUIN_IP" '
|
||||||
git -C ~/bin pull origin main
|
git -C ~/bin pull origin main
|
||||||
sudo bash -c "cat << CONF > /etc/fleet_id
|
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
|
grep -q "bin-env" ~/.zshrc 2>/dev/null || echo "[ -f \"\$HOME/bin/bin-env\" ] && source \"\$HOME/bin/bin-env\"" >> ~/.zshrc
|
||||||
|
|
||||||
~/bin/fleet-id
|
~/bin/fleet-id
|
||||||
|
~/bin/setup-sc-node
|
||||||
'
|
'
|
||||||
echo "[provision-penguin] Complete."
|
echo "[provision-penguin] Complete."
|
||||||
|
|||||||
+22
-3
@@ -24,18 +24,37 @@ find_active_server() {
|
|||||||
return 1
|
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)
|
# Determine crypto flag based on synergyc build (note: synergyc --help exits with code 3)
|
||||||
CRYPTO_FLAG=""
|
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"
|
CRYPTO_FLAG="--disable-crypto"
|
||||||
fi
|
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
|
while true; do
|
||||||
if ACTIVE_SERVER=$(find_active_server); then
|
if ACTIVE_SERVER=$(find_active_server); then
|
||||||
echo "[synergy-connect] Found active server at $ACTIVE_SERVER. Connecting..."
|
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..."
|
echo "[synergy-connect] Synergy client exited or disconnected. Probing again in 2s..."
|
||||||
else
|
else
|
||||||
echo "[synergy-connect] No reachable t520 server on Ethernet/WiFi/VPN. Retrying in 3s..."
|
echo "[synergy-connect] No reachable t520 server on Ethernet/WiFi/VPN. Retrying in 3s..."
|
||||||
|
|||||||
+13
-3
@@ -4,6 +4,16 @@ set -euo pipefail
|
|||||||
|
|
||||||
cmd="${1:-status}"
|
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
|
case "$cmd" in
|
||||||
start)
|
start)
|
||||||
echo "== Starting Synergy Server on t520 (Center) =="
|
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"
|
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) =="
|
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 ""
|
echo ""
|
||||||
"$0" status
|
"$0" status
|
||||||
@@ -28,7 +38,7 @@ case "$cmd" in
|
|||||||
systemctl --user stop synergy-server 2>/dev/null || true
|
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 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 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."
|
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"
|
ssh -o ConnectTimeout=2 bazina "systemctl --user is-active synergy-client 2>/dev/null" || echo "unreachable"
|
||||||
|
|
||||||
echo -n "penguin (Client / Left-Bottom): "
|
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): "
|
echo -n "boxC (Client / Right): "
|
||||||
ssh -o ConnectTimeout=2 boxC "systemctl --user is-active synergy-client 2>/dev/null" || echo "unreachable"
|
ssh -o ConnectTimeout=2 boxC "systemctl --user is-active synergy-client 2>/dev/null" || echo "unreachable"
|
||||||
|
|||||||
Reference in New Issue
Block a user