-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·120 lines (102 loc) · 3.51 KB
/
setup.sh
File metadata and controls
executable file
·120 lines (102 loc) · 3.51 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# Setup script for VM-to-Host Bridge
echo "====================================="
echo "VM-to-Host Bridge Setup"
echo "====================================="
# Detect if we're on Mac or Linux
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "🍎 Detected macOS - Setting up daemon..."
# Create logs directory
mkdir -p ~/Library/Logs
# Create launchd plist for auto-start
PLIST_PATH="$HOME/Library/LaunchAgents/com.user.vm-bridge.plist"
DAEMON_PATH="$HOME/Projects/vm-bridge/mac_daemon.py"
cat > "$PLIST_PATH" << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.user.vm-bridge</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/python3</string>
<string>$DAEMON_PATH</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>$HOME/Library/Logs/vm-bridge.log</string>
<key>StandardErrorPath</key>
<string>$HOME/Library/Logs/vm-bridge.error.log</string>
</dict>
</plist>
EOF
echo "✅ Created launchd configuration"
# Load the daemon
launchctl unload "$PLIST_PATH" 2>/dev/null
launchctl load "$PLIST_PATH"
echo "✅ Daemon loaded and will start automatically"
# Add vm() function to .zshrc
if ! grep -q "vm-bridge tunnel" ~/.zshrc 2>/dev/null; then
cat >> ~/.zshrc << 'EOF'
# VM connection with clipboard bridge support
vm() {
local session="${1:-main}"
echo "🔗 Connecting to VM with clipboard bridge..."
# Set up reverse tunnel for vm-bridge
mosh ericbuess@10.211.55.4 \
--ssh="ssh -R 9999:localhost:9999" \
-- tmux new-session -A -s "$session"
}
EOF
echo "✅ Added vm() function to .zshrc"
else
echo "ℹ️ vm() function already in .zshrc"
fi
echo ""
echo "🎉 Mac setup complete!"
echo ""
echo "To start using:"
echo "1. Restart your terminal or run: source ~/.zshrc"
echo "2. Connect to VM with: vm"
echo "3. The clipboard bridge will work automatically"
elif [[ "$OSTYPE" == "linux"* ]]; then
echo "🐧 Detected Linux - Setting up client..."
# Copy client library to a system location
CLIENT_DIR="$HOME/.local/lib/python/vm_bridge"
mkdir -p "$CLIENT_DIR"
cp vm_client.py "$CLIENT_DIR/"
# Create a symlink for easy import
SITE_PACKAGES=$(python3 -c "import site; print(site.USER_SITE)")
mkdir -p "$SITE_PACKAGES"
ln -sf "$CLIENT_DIR/vm_client.py" "$SITE_PACKAGES/vm_bridge.py" 2>/dev/null || true
echo "✅ Installed client library"
# Test connection
echo ""
echo "Testing connection to daemon..."
python3 -c "
import sys
sys.path.insert(0, '$CLIENT_DIR')
from vm_client import VMBridgeClient
client = VMBridgeClient()
if client.is_daemon_running():
print('✅ Successfully connected to Mac daemon!')
if client.copy_to_clipboard('VM Bridge test'):
print('✅ Clipboard test successful!')
else:
print('⚠️ Cannot connect to daemon on localhost:9999')
print(' Make sure you connected with SSH tunnel: -R 9999:localhost:9999')
"
echo ""
echo "🎉 Linux setup complete!"
echo ""
echo "To use in Python scripts:"
echo " from vm_bridge import copy_to_mac_clipboard"
echo " copy_to_mac_clipboard('content')"
else
echo "❌ Unsupported OS: $OSTYPE"
exit 1
fi