#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
cd "$ROOT_DIR"

if [ ! -f ".env" ]; then
  echo "Fel: .env saknas i $ROOT_DIR"
  exit 1
fi

if grep -q '^RECEIPT_TRACE_DECISIONS=' .env; then
  sed -i 's/^RECEIPT_TRACE_DECISIONS=.*/RECEIPT_TRACE_DECISIONS=0/' .env
else
  echo 'RECEIPT_TRACE_DECISIONS=0' >> .env
fi

echo "RECEIPT_TRACE_DECISIONS=0 satt i .env"

echo "Startar om recipe-api utan full trace..."
docker compose -f compose.yml -f compose.flutter.yml up -d recipe-api

echo "Klart."
