Files
mediaproc/ctrl/run.sh
2026-03-23 09:58:40 -03:00

66 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
# Run MPR stack locally
# Usage: ./run.sh [OPTIONS] [docker-compose args]
#
# Options:
# -d, --detach Run detached (background)
# --build Rebuild images before starting
# stop Stop all services
#
# Examples:
# ./run.sh # Start attached (see logs)
# ./run.sh -d # Start detached
# ./run.sh --build # Rebuild and start
# ./run.sh stop # Stop all services
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Load env
if [ -f .env ]; then
set -a
source .env
set +a
else
echo "Warning: .env not found, using defaults"
echo "Copy .env.template to .env to customize"
fi
# Check /etc/hosts
if ! grep -q "mpr.local.ar" /etc/hosts 2>/dev/null; then
echo "Note: Add to /etc/hosts:"
echo " 127.0.0.1 mpr.local.ar"
echo ""
fi
# Parse options
DETACH=""
BUILD=""
while [[ $# -gt 0 ]]; do
case $1 in
-d|--detach)
DETACH="-d"
shift
;;
--build)
BUILD="--build"
shift
;;
stop)
docker compose down
exit $?
;;
*)
# Pass remaining args to docker compose
docker compose "$@"
exit $?
;;
esac
done
# Default: up attached
docker compose up $DETACH $BUILD