Initial commit: vixy-vision distributed sensing system
🦊 Eyes and ears for the fox Components: - server/: Camera server for Raspberry Pi (from camera-server) - mcp/: Vision MCP client for Claude Desktop (from vision-mcp) - analysis/: Placeholder for motion/audio detection - shared/: Common schemas and interfaces Features: - Setup script with systemd service creation - HTTPS + API key authentication - HTTP and RTSP camera support Built under a blanket on Day 45 💕
This commit is contained in:
157
server/setup.sh
Normal file
157
server/setup.sh
Normal file
@@ -0,0 +1,157 @@
|
||||
#!/bin/bash
|
||||
# vixy-vision Server Setup Script
|
||||
# Run this on a Raspberry Pi or similar edge device
|
||||
#
|
||||
# Usage: ./setup.sh [--with-audio]
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
INSTALL_DIR="${HOME}/vixy-vision"
|
||||
SERVICE_NAME="vixy-vision"
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
|
||||
echo_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
|
||||
echo_error() { echo -e "${RED}[ERROR]${NC} $1"; }
|
||||
|
||||
# Parse arguments
|
||||
WITH_AUDIO=false
|
||||
for arg in "$@"; do
|
||||
case $arg in
|
||||
--with-audio)
|
||||
WITH_AUDIO=true
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo "=========================================="
|
||||
echo " vixy-vision Server Setup"
|
||||
echo " Eyes and ears for the fox 🦊"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Check if running on Linux
|
||||
if [[ "$(uname)" != "Linux" ]]; then
|
||||
echo_error "This script is designed for Linux (Raspberry Pi)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install system dependencies
|
||||
echo_info "Installing system dependencies..."
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-pip python3-venv libopencv-dev
|
||||
|
||||
if [ "$WITH_AUDIO" = true ]; then
|
||||
echo_info "Installing audio dependencies..."
|
||||
sudo apt-get install -y portaudio19-dev python3-pyaudio alsa-utils
|
||||
fi
|
||||
|
||||
# Create install directory
|
||||
echo_info "Creating install directory: ${INSTALL_DIR}"
|
||||
mkdir -p "${INSTALL_DIR}"
|
||||
cp -r "${SCRIPT_DIR}"/* "${INSTALL_DIR}/"
|
||||
|
||||
# Create virtual environment
|
||||
echo_info "Creating Python virtual environment..."
|
||||
cd "${INSTALL_DIR}"
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
|
||||
# Install Python dependencies
|
||||
echo_info "Installing Python dependencies..."
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
|
||||
if [ "$WITH_AUDIO" = true ]; then
|
||||
pip install pyaudio webrtcvad numpy
|
||||
fi
|
||||
|
||||
# Generate SSL certificates
|
||||
echo_info "Generating SSL certificates..."
|
||||
chmod +x generate_cert.sh
|
||||
./generate_cert.sh
|
||||
|
||||
# Generate API key if .env doesn't exist
|
||||
if [ ! -f .env ]; then
|
||||
echo_info "Generating API key..."
|
||||
API_KEY=$(python3 -c 'import secrets; print(secrets.token_urlsafe(32))')
|
||||
cat > .env << EOF
|
||||
# vixy-vision Server Configuration
|
||||
# Generated by setup.sh on $(date)
|
||||
|
||||
# API Key for authentication (keep secret!)
|
||||
API_KEY=${API_KEY}
|
||||
|
||||
# Camera settings
|
||||
CAMERA_INDEX=0
|
||||
CAMERA_WIDTH=1920
|
||||
CAMERA_HEIGHT=1080
|
||||
JPEG_QUALITY=85
|
||||
EOF
|
||||
echo_info "API key generated and saved to .env"
|
||||
echo ""
|
||||
echo_warn "IMPORTANT: Save this API key for your MCP config:"
|
||||
echo -e " ${GREEN}${API_KEY}${NC}"
|
||||
echo ""
|
||||
else
|
||||
echo_info "Using existing .env file"
|
||||
fi
|
||||
|
||||
# Create systemd service
|
||||
echo_info "Creating systemd service..."
|
||||
sudo tee /etc/systemd/system/${SERVICE_NAME}.service > /dev/null << EOF
|
||||
[Unit]
|
||||
Description=vixy-vision Camera Server
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=${USER}
|
||||
WorkingDirectory=${INSTALL_DIR}
|
||||
Environment="PATH=${INSTALL_DIR}/venv/bin"
|
||||
ExecStart=${INSTALL_DIR}/venv/bin/uvicorn main:app --host 0.0.0.0 --port 8443 --ssl-keyfile ssl/key.pem --ssl-certfile ssl/cert.pem
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# Reload systemd and enable service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable ${SERVICE_NAME}
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " Setup Complete! 🦊"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " Start: sudo systemctl start ${SERVICE_NAME}"
|
||||
echo " Stop: sudo systemctl stop ${SERVICE_NAME}"
|
||||
echo " Status: sudo systemctl status ${SERVICE_NAME}"
|
||||
echo " Logs: sudo journalctl -u ${SERVICE_NAME} -f"
|
||||
echo ""
|
||||
echo "Server will be available at:"
|
||||
echo " https://$(hostname -I | awk '{print $1}'):8443/"
|
||||
echo ""
|
||||
echo "Add to Vixy's vision config (~/.vision_setup.json):"
|
||||
echo " {"
|
||||
echo " \"cameras\": ["
|
||||
echo " {"
|
||||
echo " \"id\": \"$(hostname)\","
|
||||
echo " \"type\": \"http\","
|
||||
echo " \"url\": \"https://$(hostname -I | awk '{print $1}'):8443\","
|
||||
echo " \"api_key\": \"<your-api-key-from-above>\""
|
||||
echo " }"
|
||||
echo " ]"
|
||||
echo " }"
|
||||
echo ""
|
||||
echo_info "Start the server with: sudo systemctl start ${SERVICE_NAME}"
|
||||
Reference in New Issue
Block a user