#!/bin/bash # Stella's Orly Relay Management Script # Uses docker-compose.yml directly for configuration set -e # Get script directory and project root SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$SCRIPT_DIR" # Configuration from docker-compose.yml RELAY_SERVICE="stella-relay" CONTAINER_NAME="stella-nostr-relay" RELAY_URL="ws://127.0.0.1:7777" HTTP_URL="http://127.0.0.1:7777" RELAY_DATA_DIR="/home/madmin/.local/share/orly-relay" # Change to project directory for docker-compose commands cd "$PROJECT_DIR" case "${1:-}" in "start") echo "๐Ÿš€ Starting Stella's Orly Relay..." docker compose up -d stella-relay echo "โœ… Relay started!" ;; "stop") echo "โน๏ธ Stopping Stella's Orly Relay..." docker compose down echo "โœ… Relay stopped!" ;; "restart") echo "๐Ÿ”„ Restarting Stella's Orly Relay..." docker compose restart stella-relay echo "โœ… Relay restarted!" ;; "status") echo "๐Ÿ“Š Stella's Orly Relay Status:" docker compose ps stella-relay ;; "logs") echo "๐Ÿ“œ Stella's Orly Relay Logs:" docker compose logs -f stella-relay ;; "test") echo "๐Ÿงช Testing relay connection..." if curl -s -I "$HTTP_URL" | grep -q "426 Upgrade Required"; then echo "โœ… Relay is responding correctly!" echo "๐Ÿ“ก WebSocket URL: $RELAY_URL" echo "๐ŸŒ HTTP URL: $HTTP_URL" else echo "โŒ Relay is not responding correctly" echo " Expected: 426 Upgrade Required" echo " URL: $HTTP_URL" exit 1 fi ;; "enable") echo "๐Ÿ”ง Enabling relay to start at boot..." sudo systemctl enable $RELAY_SERVICE echo "โœ… Relay will start automatically at boot!" ;; "disable") echo "๐Ÿ”ง Disabling relay auto-start..." sudo systemctl disable $RELAY_SERVICE echo "โœ… Relay will not start automatically at boot!" ;; "info") echo "๐Ÿ“‹ Stella's Orly Relay Information:" echo " Service: $RELAY_SERVICE" echo " Container: $CONTAINER_NAME" echo " WebSocket URL: $RELAY_URL" echo " HTTP URL: $HTTP_URL" echo " Data Directory: $RELAY_DATA_DIR" echo " Config Directory: $PROJECT_DIR" echo "" echo "๐Ÿณ Docker Information:" echo " Compose File: $PROJECT_DIR/docker-compose.yml" echo " Container Status:" docker compose ps stella-relay 2>/dev/null || echo " Not running" echo "" echo "๐Ÿ’ก Configuration:" echo " All settings are defined in docker-compose.yml" echo " Use 'docker compose config' to see parsed configuration" ;; "docker-logs") echo "๐Ÿณ Docker Container Logs:" docker compose logs -f stella-relay 2>/dev/null || echo "โŒ Container not found or not running" ;; "docker-status") echo "๐Ÿณ Docker Container Status:" docker compose ps stella-relay ;; "docker-restart") echo "๐Ÿ”„ Restarting Docker Container..." docker compose restart stella-relay echo "โœ… Container restarted!" ;; "docker-update") echo "๐Ÿ”„ Updating and restarting Docker Container..." docker compose pull stella-relay docker compose up -d stella-relay echo "โœ… Container updated and restarted!" ;; "docker-build") echo "๐Ÿ”จ Building Docker Container..." docker compose build stella-relay echo "โœ… Container built!" ;; "docker-down") echo "โน๏ธ Stopping Docker Container..." docker compose down echo "โœ… Container stopped!" ;; "docker-config") echo "๐Ÿ“‹ Docker Compose Configuration:" docker compose config ;; *) echo "๐ŸŒฒ Stella's Orly Relay Management Script" echo "" echo "Usage: $0 [COMMAND]" echo "" echo "Commands:" echo " start Start the relay" echo " stop Stop the relay" echo " restart Restart the relay" echo " status Show relay status" echo " logs Show relay logs (follow mode)" echo " test Test relay connection" echo " enable Enable auto-start at boot" echo " disable Disable auto-start at boot" echo " info Show relay information" echo "" echo "Docker Commands:" echo " docker-logs Show Docker container logs" echo " docker-status Show Docker container status" echo " docker-restart Restart Docker container only" echo " docker-update Update and restart container" echo " docker-build Build Docker container" echo " docker-down Stop Docker container" echo " docker-config Show Docker Compose configuration" echo "" echo "Examples:" echo " $0 start # Start the relay" echo " $0 status # Check if it's running" echo " $0 test # Test WebSocket connection" echo " $0 logs # Watch real-time logs" echo " $0 docker-logs # Watch Docker container logs" echo " $0 docker-update # Update and restart container" echo "" echo "๐ŸŒฒ Crafted in the digital forest by Stella โœจ" ;; esac