85 lines
2.5 KiB
Bash
85 lines
2.5 KiB
Bash
#!/usr/bin/env bash
|
|
# One-time setup script for Ubuntu environment.
|
|
# Installs system dependencies, sets up the Python venv, and prepares .env.
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
echo "=== Homey MCP Server Ubuntu Setup ==="
|
|
|
|
# 1. Check Python version
|
|
PYTHON_CMD=""
|
|
if command -v python3 &>/dev/null; then
|
|
PYTHON_CMD="python3"
|
|
elif command -v python &>/dev/null; then
|
|
PYTHON_CMD="python"
|
|
else
|
|
echo "ERROR: Python not found. Install Python 3.10+ first."
|
|
echo " Ubuntu: sudo apt install python3.10 python3.venv"
|
|
exit 1
|
|
fi
|
|
|
|
PY_VER=$($PYTHON_CMD -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')
|
|
echo "Found Python $PY_VER"
|
|
|
|
# 2. Install system dependencies if needed
|
|
if ! command -v uvicorn &>/dev/null 2>&1; then
|
|
echo "Installing system dependencies..."
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y python3-pip python3-dev python3-venv build-essential libffi-dev libssl-dev
|
|
fi
|
|
|
|
# 3. Create virtual environment if it doesn't exist
|
|
if [ ! -d ".venv" ]; then
|
|
echo "Creating virtual environment..."
|
|
$PYTHON_CMD -m venv .venv
|
|
fi
|
|
|
|
source .venv/bin/activate
|
|
|
|
# 4. Install/update Python dependencies
|
|
echo "Installing Python dependencies..."
|
|
$PYTHON_CMD -m pip install --upgrade pip >/dev/null 2>&1
|
|
pip install -e . >/dev/null 2>&1
|
|
pip install uvicorn >/dev/null 2>&1
|
|
|
|
# 5. Create .env file from example if it doesn't exist
|
|
if [ ! -f ".env" ]; then
|
|
if [ -f ".env.example" ]; then
|
|
echo "Creating .env from .env.example (please edit with your credentials)..."
|
|
cp .env.example .env
|
|
else
|
|
echo "Creating minimal .env file..."
|
|
cat > .env << 'EOF'
|
|
# Homey Pro API configuration
|
|
HOMEY_HOST=your-homey-pro-ip
|
|
HOMEY_TOKEN=your_homey_api_token_here
|
|
HOMEY_SCHEME=http
|
|
HOMEY_PORT=4859
|
|
|
|
# MCP server configuration (LAN mode)
|
|
HOMEY_MCP_TRANSPORT=streamable-http
|
|
HOMEY_MCP_HOST=0.0.0.0
|
|
HOMEY_MCP_ADVERTISED_HOST=<your-server-ip>
|
|
HOMEY_MCP_PORT=8080
|
|
HOMEY_MCP_AUTH_MODE=none
|
|
HOMEY_MCP_AUTH_TOKEN=your_mcp_auth_token_here
|
|
|
|
# Socket.IO realtime configuration (optional)
|
|
HOMEY_REALTIME=true
|
|
EOF
|
|
fi
|
|
fi
|
|
|
|
echo ""
|
|
echo "=== Setup complete! ==="
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Edit .env with your Homey Pro credentials (HOMEY_TOKEN and HOMEY_HOST)"
|
|
echo "2. For LAN mode (recommended for Odysseus): ./run-lan.sh"
|
|
echo "3. For local stdio mode: ./run.sh"
|
|
echo ""
|
|
echo "For persistent operation, install the systemd service:"
|
|
echo " sudo cp homey-mcp.service /etc/systemd/system/"
|
|
echo " sudo systemctl daemon-reload"
|
|
echo " sudo systemctl enable --now homey-mcp@$(whoami).service"
|
|
echo "" |