-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopencode-forward
More file actions
executable file
·45 lines (43 loc) · 1.48 KB
/
Copy pathopencode-forward
File metadata and controls
executable file
·45 lines (43 loc) · 1.48 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
#!/bin/bash
# opencode-forward - Control the OpenCode web server service
# Runs opencode serve on 0.0.0.0:4096 so devices on LAN can access it
SERVICE="com.opencode.serve-lan"
PLIST="$HOME/Library/LaunchAgents/$SERVICE.plist"
case "${1:-}" in
start)
launchctl load "$PLIST" 2>/dev/null
echo "OpenCode serve started (0.0.0.0:4096)"
IP=$(ipconfig getifaddr en0 2>/dev/null || echo "unknown")
echo "Access from phone: http://$IP:4096"
;;
stop)
launchctl unload "$PLIST" 2>/dev/null
echo "OpenCode serve stopped"
;;
status)
if launchctl list "$SERVICE" &>/dev/null; then
IP=$(ipconfig getifaddr en0 2>/dev/null || echo "unknown")
echo "Running - http://$IP:4096"
else
echo "Stopped"
fi
;;
logs)
tail -f /tmp/opencode-serve-lan.log
;;
uninstall)
launchctl unload "$PLIST" 2>/dev/null
rm -f "$PLIST"
echo "OpenCode serve uninstalled"
echo "You can delete this script with: rm ~/.local/bin/opencode-forward"
;;
*)
echo "Usage: opencode-forward {start|stop|status|logs|uninstall}"
echo ""
echo " start Start opencode serve (survives sleep/reboot)"
echo " stop Stop opencode serve"
echo " status Check if running and show URL"
echo " logs Tail the service logs"
echo " uninstall Remove the service completely"
;;
esac