# Core Room Control Scripts

Control scripts for managing the core_room deployment (amar + soleprint).

## Structure

```
ctrl/
├── .env.sync          # Configuration for deploy
├── .exclude           # Rsync exclusion patterns
├── build.sh           # Build Docker images (auto-detects services)
├── deploy.sh          # Deploy to server (sync all files)
├── logs.sh            # View container logs
├── setup.sh           # Initial setup (nginx, certs, .env)
├── start.sh           # Start Docker services
├── status.sh          # Show container status
├── stop.sh            # Stop Docker services
└── manual_sync/       # Source code sync scripts
    ├── sync_ama.sh    # Sync amar source code
    └── sync_soleprint.sh  # Sync soleprint source code
```

## Configuration

Edit `.env.sync` to configure deployment:

```bash
# Server
DEPLOY_SERVER=mariano@mcrn.ar
DEPLOY_REMOTE_PATH=~/core_room

# Local paths
LOCAL_SOLEPRINT_PATH=/home/mariano/wdir/ama/soleprint
LOCAL_AMAR_BASE=/home/mariano/wdir/ama

# Remote paths
REMOTE_SOLEPRINT_PATH=/home/mariano/soleprint
REMOTE_AMAR_PATH=/home/mariano/core_room/amar/src
```

## Usage

### Full Deployment
```bash
cd ctrl
./deploy.sh              # Deploy everything to server
./deploy.sh --dry-run    # Preview what would be synced

# Then on server:
ssh server 'cd ~/core_room/ctrl && ./build.sh && ./start.sh -d'
```

### Local Development
```bash
./start.sh               # Start all services (foreground, see logs)
./start.sh -d            # Start all services (detached)
./start.sh --build       # Start with rebuild
./start.sh -d --build    # Detached with rebuild
./logs.sh                # View logs
./stop.sh                # Stop all services
```

### Service Management
```bash
# All scripts auto-detect services (any dir with docker-compose.yml)

./build.sh               # Build all images
./build.sh amar          # Build only amar images
./build.sh --no-cache    # Force rebuild without cache

./start.sh               # Start all (foreground)
./start.sh -d            # Start all (detached)
./start.sh amar          # Start specific service
./start.sh --build       # Start with rebuild

./stop.sh                # Stop all services
./stop.sh amar           # Stop specific service

./logs.sh                # View all logs
./logs.sh amar           # View amar compose logs
./logs.sh backend        # View specific container logs

./status.sh              # Show container status
```

## Room vs Soleprint Control

- **core_room/ctrl/** - Manages the full room (amar + soleprint) via Docker
- **soleprint/ctrl/** - Manages soleprint services via systemd (alternative deployment)

Use core_room/ctrl for orchestrating the full room with Docker Compose.
Use soleprint/ctrl for direct systemd deployment of soleprint services only.
