start script
This commit is contained in:
59
apps/homekit/start_bridge.sh
Executable file
59
apps/homekit/start_bridge.sh
Executable file
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# HomeKit Bridge Startup Script
|
||||||
|
# This script sets up the virtual environment, installs dependencies, and starts the bridge
|
||||||
|
|
||||||
|
set -e # Exit on error
|
||||||
|
|
||||||
|
# Change to script directory
|
||||||
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
cd "$SCRIPT_DIR"
|
||||||
|
|
||||||
|
echo "🏠 HomeKit Bridge Startup"
|
||||||
|
echo "========================="
|
||||||
|
|
||||||
|
# Virtual environment path
|
||||||
|
VENV_DIR="$SCRIPT_DIR/venv"
|
||||||
|
|
||||||
|
# Check if virtual environment exists
|
||||||
|
if [ ! -d "$VENV_DIR" ]; then
|
||||||
|
echo "📦 Virtual environment not found. Creating..."
|
||||||
|
python3 -m venv "$VENV_DIR"
|
||||||
|
echo "✅ Virtual environment created at $VENV_DIR"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Activate virtual environment
|
||||||
|
echo "🔧 Activating virtual environment..."
|
||||||
|
source "$VENV_DIR/bin/activate"
|
||||||
|
|
||||||
|
# Install/update dependencies
|
||||||
|
echo "📥 Installing dependencies from requirements.txt..."
|
||||||
|
pip install --upgrade pip -q
|
||||||
|
pip install -r requirements.txt -q
|
||||||
|
echo "✅ Dependencies installed"
|
||||||
|
|
||||||
|
# Set environment variables (with defaults)
|
||||||
|
export HOMEKIT_NAME="${HOMEKIT_NAME:-Home Automation Bridge}"
|
||||||
|
export HOMEKIT_PIN="${HOMEKIT_PIN:-031-45-154}"
|
||||||
|
export HOMEKIT_PORT="${HOMEKIT_PORT:-51826}"
|
||||||
|
export API_BASE="${API_BASE:-http://172.19.1.11:8001}"
|
||||||
|
export HOMEKIT_API_TOKEN="${HOMEKIT_API_TOKEN:-}"
|
||||||
|
export HOMEKIT_PERSIST_FILE="${HOMEKIT_PERSIST_FILE:-$SCRIPT_DIR/homekit.state}"
|
||||||
|
|
||||||
|
# Display configuration
|
||||||
|
echo ""
|
||||||
|
echo "⚙️ Configuration:"
|
||||||
|
echo " Bridge Name: $HOMEKIT_NAME"
|
||||||
|
echo " Bridge PIN: $HOMEKIT_PIN"
|
||||||
|
echo " Bridge Port: $HOMEKIT_PORT"
|
||||||
|
echo " API Base URL: $API_BASE"
|
||||||
|
echo " Persist File: $HOMEKIT_PERSIST_FILE"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Start the bridge
|
||||||
|
echo "🚀 Starting HomeKit Bridge..."
|
||||||
|
echo " (Press Ctrl+C to stop)"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Run the bridge using Python module syntax
|
||||||
|
python -m apps.homekit.main
|
||||||
Reference in New Issue
Block a user