Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

implement auto-start scripts (P6 feature 3/4)

botb9a623be80dd
diff --git a/scripts/README.md b/scripts/README.md
new file mode 100644
index 00000000..c07dd1ba
--- /dev/null
+++ b/scripts/README.md
@@ -0,0 +1,76 @@
+# Pinchtab Scripts
+
+## Auto-Start Setup
+
+### Quick Install
+
+```bash
+./scripts/install-autostart.sh
+```
+
+This will:
+- Build and install pinchtab to `/usr/local/bin`
+- Configure auto-start on boot
+- Start the service immediately
+
+### macOS (launchd)
+
+The installer creates a LaunchAgent that:
+- Runs pinchtab on login
+- Restarts automatically if it crashes
+- Logs to `/tmp/pinchtab.*.log`
+
+Manual control:
+```bash
+# Start/stop
+launchctl start com.pinchtab.bridge
+launchctl stop com.pinchtab.bridge
+
+# Check status
+launchctl list | grep pinchtab
+
+# View logs
+tail -f /tmp/pinchtab.*.log
+```
+
+### Linux (systemd)
+
+The installer creates a systemd user service that:
+- Runs pinchtab on boot
+- Restarts automatically if it crashes
+- Logs to systemd journal
+
+Manual control:
+```bash
+# Start/stop
+sudo systemctl start pinchtab@$USER
+sudo systemctl stop pinchtab@$USER
+
+# Check status
+sudo systemctl status pinchtab@$USER
+
+# View logs
+sudo journalctl -u pinchtab@$USER -f
+```
+
+### Uninstall
+
+```bash
+./scripts/uninstall-autostart.sh
+```
+
+### Custom Configuration
+
+Edit environment variables in:
+- **macOS**: `~/Library/LaunchAgents/com.pinchtab.bridge.plist`
+- **Linux**: `/etc/systemd/system/[email protected]`
+
+Common environment variables:
+- `BRIDGE_PORT` - HTTP port (default: 9867)
+- `BRIDGE_TOKEN` - Auth token (optional)
+- `BRIDGE_HEADLESS` - Run Chrome headless (default: true)
+- `BRIDGE_PROFILE` - Chrome profile directory
+
+## Other Scripts
+
+- `check.sh` - Run all pre-push checks (format, vet, build, test)
\ No newline at end of file
diff --git a/scripts/install-autostart.sh b/scripts/install-autostart.sh
new file mode 100755
index 00000000..a8ae5aa3
--- /dev/null
+++ b/scripts/install-autostart.sh
@@ -0,0 +1,91 @@
+#!/bin/bash
+set -e
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+PINCHTAB_BIN="$(cd "$SCRIPT_DIR/.." && pwd)/pinchtab"
+
+echo "πŸ¦€ Pinchtab Auto-Start Installer"
+echo "================================"
+
+# Detect OS
+if [[ "$OSTYPE" == "darwin"* ]]; then
+ # macOS
+ echo "Detected macOS - using launchd"
+
+ # Build if needed
+ if [ ! -f "$PINCHTAB_BIN" ]; then
+ echo "Building pinchtab..."
+ (cd "$SCRIPT_DIR/.." && go build -o pinchtab .)
+ fi
+
+ # Copy binary to /usr/local/bin
+ echo "Installing pinchtab to /usr/local/bin..."
+ sudo cp "$PINCHTAB_BIN" /usr/local/bin/pinchtab
+
+ # Install LaunchAgent
+ PLIST_SRC="$SCRIPT_DIR/launchd/com.pinchtab.bridge.plist"
+ PLIST_DST="$HOME/Library/LaunchAgents/com.pinchtab.bridge.plist"
+
+ echo "Installing LaunchAgent..."
+ mkdir -p "$HOME/Library/LaunchAgents"
+ cp "$PLIST_SRC" "$PLIST_DST"
+
+ # Load the agent
+ echo "Loading LaunchAgent..."
+ launchctl load -w "$PLIST_DST" 2>/dev/null || true
+
+ echo ""
+ echo "βœ… Pinchtab installed and set to auto-start!"
+ echo ""
+ echo "Commands:"
+ echo " Start: launchctl start com.pinchtab.bridge"
+ echo " Stop: launchctl stop com.pinchtab.bridge"
+ echo " Status: launchctl list | grep pinchtab"
+ echo " Logs: tail -f /tmp/pinchtab.*.log"
+ echo " Disable: launchctl unload ~/Library/LaunchAgents/com.pinchtab.bridge.plist"
+
+elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
+ # Linux
+ echo "Detected Linux - using systemd"
+
+ # Build if needed
+ if [ ! -f "$PINCHTAB_BIN" ]; then
+ echo "Building pinchtab..."
+ (cd "$SCRIPT_DIR/.." && go build -o pinchtab .)
+ fi
+
+ # Copy binary to /usr/local/bin
+ echo "Installing pinchtab to /usr/local/bin..."
+ sudo cp "$PINCHTAB_BIN" /usr/local/bin/pinchtab
+
+ # Install systemd service
+ SERVICE_SRC="$SCRIPT_DIR/systemd/pinchtab.service"
+ SERVICE_DST="/etc/systemd/system/[email protected]"
+
+ echo "Installing systemd service..."
+ sudo cp "$SERVICE_SRC" "$SERVICE_DST"
+
+ # Enable and start service
+ echo "Enabling service for user $USER..."
+ sudo systemctl daemon-reload
+ sudo systemctl enable "pinchtab@$USER.service"
+ sudo systemctl start "pinchtab@$USER.service"
+
+ echo ""
+ echo "βœ… Pinchtab installed and set to auto-start!"
+ echo ""
+ echo "Commands:"
+ echo " Start: sudo systemctl start pinchtab@$USER"
+ echo " Stop: sudo systemctl stop pinchtab@$USER"
+ echo " Status: sudo systemctl status pinchtab@$USER"
+ echo " Logs: sudo journalctl -u pinchtab@$USER -f"
+ echo " Disable: sudo systemctl disable pinchtab@$USER"
+
+else
+ echo "❌ Unsupported OS: $OSTYPE"
+ echo "Please manually configure auto-start for your system."
+ exit 1
+fi
+
+echo ""
+echo "Test with: curl http://localhost:9867/health"
\ No newline at end of file
diff --git a/scripts/launchd/com.pinchtab.bridge.plist b/scripts/launchd/com.pinchtab.bridge.plist
new file mode 100644
index 00000000..dd9cc465
--- /dev/null
+++ b/scripts/launchd/com.pinchtab.bridge.plist
@@ -0,0 +1,38 @@
+<?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.pinchtab.bridge</string>
+
+ <key>ProgramArguments</key>
+ <array>
+ <string>/usr/local/bin/pinchtab</string>
+ </array>
+
+ <key>EnvironmentVariables</key>
+ <dict>
+ <key>BRIDGE_PORT</key>
+ <string>9867</string>
+ <key>BRIDGE_HEADLESS</key>
+ <string>true</string>
+ <key>BRIDGE_PROFILE</key>
+ <string>~/.pinchtab/chrome-profile</string>
+ </dict>
+
+ <key>RunAtLoad</key>
+ <true/>
+
+ <key>KeepAlive</key>
+ <true/>
+
+ <key>StandardOutPath</key>
+ <string>/tmp/pinchtab.out.log</string>
+
+ <key>StandardErrorPath</key>
+ <string>/tmp/pinchtab.err.log</string>
+
+ <key>ProcessType</key>
+ <string>Interactive</string>
+</dict>
+</plist>
\ No newline at end of file
diff --git a/scripts/systemd/pinchtab.service b/scripts/systemd/pinchtab.service
new file mode 100644
index 00000000..25a61e99
--- /dev/null
+++ b/scripts/systemd/pinchtab.service
@@ -0,0 +1,28 @@
+[Unit]
+Description=Pinchtab Browser Automation Bridge
+Documentation=https://github.com/pinchtab/pinchtab
+After=network.target
+
+[Service]
+Type=simple
+User=%i
+ExecStart=/usr/local/bin/pinchtab
+Restart=always
+RestartSec=5
+
+# Environment
+Environment="BRIDGE_PORT=9867"
+Environment="BRIDGE_HEADLESS=true"
+Environment="BRIDGE_PROFILE=%h/.pinchtab/chrome-profile"
+Environment="DISPLAY=:0"
+
+# Logging
+StandardOutput=journal
+StandardError=journal
+
+# Security
+NoNewPrivileges=true
+PrivateTmp=true
+
+[Install]
+WantedBy=default.target
\ No newline at end of file
diff --git a/scripts/uninstall-autostart.sh b/scripts/uninstall-autostart.sh
new file mode 100755
index 00000000..f6d15f5b
--- /dev/null
+++ b/scripts/uninstall-autostart.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+set -e
+
+echo "πŸ¦€ Pinchtab Auto-Start Uninstaller"
+echo "==================================="
+
+# Detect OS
+if [[ "$OSTYPE" == "darwin"* ]]; then
+ # macOS
+ echo "Detected macOS - removing launchd configuration"
+
+ PLIST="$HOME/Library/LaunchAgents/com.pinchtab.bridge.plist"
+
+ # Unload if running
+ echo "Stopping Pinchtab..."
+ launchctl unload "$PLIST" 2>/dev/null || true
+
+ # Remove plist
+ if [ -f "$PLIST" ]; then
+ echo "Removing LaunchAgent..."
+ rm "$PLIST"
+ fi
+
+ # Optionally remove binary
+ read -p "Remove /usr/local/bin/pinchtab? (y/N): " -n 1 -r
+ echo
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ sudo rm -f /usr/local/bin/pinchtab
+ fi
+
+elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
+ # Linux
+ echo "Detected Linux - removing systemd configuration"
+
+ # Stop and disable service
+ echo "Stopping Pinchtab..."
+ sudo systemctl stop "pinchtab@$USER" 2>/dev/null || true
+ sudo systemctl disable "pinchtab@$USER" 2>/dev/null || true
+
+ # Remove service file
+ if [ -f "/etc/systemd/system/[email protected]" ]; then
+ echo "Removing systemd service..."
+ sudo rm "/etc/systemd/system/[email protected]"
+ sudo systemctl daemon-reload
+ fi
+
+ # Optionally remove binary
+ read -p "Remove /usr/local/bin/pinchtab? (y/N): " -n 1 -r
+ echo
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ sudo rm -f /usr/local/bin/pinchtab
+ fi
+
+else
+ echo "❌ Unsupported OS: $OSTYPE"
+ exit 1
+fi
+
+echo ""
+echo "βœ… Pinchtab auto-start has been removed!"
\ No newline at end of file