#!/usr/bin/env bash set -euo pipefail # One-command deploy of the KosmoConnect Bridge Daemon to a Raspberry Pi # Run this script from your dev machine. Requires ssh access to the Pi. PI_HOST="${1:-}" PI_USER="${2:-pi}" INSTALL_DIR="/opt/kosmo-bridge" if [ -z "$PI_HOST" ]; then echo "Usage: ./deploy-pi.sh [pi-user]" echo "Example: ./deploy-pi.sh 192.168.1.50 pi" exit 1 fi echo "=== Deploying KosmoConnect Bridge Daemon to $PI_USER@$PI_HOST ===" # 1. Ensure target directory exists ssh "$PI_USER@$PI_HOST" "sudo mkdir -p $INSTALL_DIR && sudo chown $PI_USER:$PI_USER $INSTALL_DIR" # 2. Sync source files rsync -avz --delete \ src/ \ requirements.txt \ kosmo-bridge.service \ install.sh \ "$PI_USER@$PI_HOST:$INSTALL_DIR/" # 3. Run installer remotely ssh "$PI_USER@$PI_HOST" "cd $INSTALL_DIR && sudo ./install.sh" echo "" echo "===========================================" echo "Deployment complete." echo "" echo "Next steps on the Pi:" echo " ssh $PI_USER@$PI_HOST" echo " sudo systemctl edit --full kosmo-bridge" echo " # Set MQTT_HOST, MESHTASTIC_HOST, etc." echo " sudo systemctl daemon-reload" echo " sudo systemctl restart kosmo-bridge" echo " sudo journalctl -u kosmo-bridge -f" echo "==========================================="