#!/bin/bash # WHOOSH MCP Server Service Installation Script set -e echo "🐝 Installing WHOOSH MCP Server as a systemd service..." # Check if running as root if [[ $EUID -eq 0 ]]; then echo "❌ This script should not be run as root. Run as the user who will own the service." exit 1 fi # Verify the service file exists if [ ! -f "whoosh-mcp.service" ]; then echo "❌ Service file 'whoosh-mcp.service' not found in current directory" exit 1 fi # Verify the built application exists if [ ! -f "dist/index.js" ]; then echo "❌ Built application not found. Run 'npm run build' first." exit 1 fi # Create log and data directories with proper permissions echo "📁 Creating directories..." mkdir -p logs data chmod 755 logs data # Copy service file to systemd directory echo "📄 Installing service file..." sudo cp whoosh-mcp.service /etc/systemd/system/ # Reload systemd daemon echo "🔄 Reloading systemd daemon..." sudo systemctl daemon-reload # Enable the service echo "✅ Enabling WHOOSH MCP service..." sudo systemctl enable whoosh-mcp.service echo "" echo "🎉 WHOOSH MCP Server service installed successfully!" echo "" echo "📋 Available commands:" echo " sudo systemctl start whoosh-mcp # Start the service" echo " sudo systemctl stop whoosh-mcp # Stop the service" echo " sudo systemctl restart whoosh-mcp # Restart the service" echo " sudo systemctl status whoosh-mcp # Check service status" echo " sudo systemctl disable whoosh-mcp # Disable auto-start" echo " journalctl -u whoosh-mcp -f # View live logs" echo " sudo systemctl reload whoosh-mcp # Trigger agent discovery" echo "" echo "🚀 To start the service now, run:" echo " sudo systemctl start whoosh-mcp" echo "" echo "📊 To check the status, run:" echo " sudo systemctl status whoosh-mcp"