#!/usr/bin/env bash
# Pull latest from Dropbox (EtherGold + DyzineFrame), then apply bench profile.
#
# Usage:
#   cd ~/EtherGold/sync
#   DRY_RUN=1 bash pull_and_apply_bench.sh    # preview pull only
#   bash pull_and_apply_bench.sh
#
# Pull only (no bench profile):
#   SKIP_BENCH_PROFILE=1 bash pull_and_apply_bench.sh
#   — or: bash pull_all_from_dropbox.sh

if grep -q $'\r' "${BASH_SOURCE[0]}" 2>/dev/null; then
  sed -i 's/\r$//' "${BASH_SOURCE[0]}"
  exec bash "${BASH_SOURCE[0]}" "$@"
fi

set -euo pipefail

SYNC="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

if [[ "${SKIP_BENCH_PROFILE:-0}" == "1" ]]; then
  bash "${SYNC}/pull_all_from_dropbox.sh"
  echo "SKIP_BENCH_PROFILE=1 — bench profile skipped"
  exit 0
fi

APPLY_BENCH_PROFILE=1 bash "${SYNC}/pull_all_from_dropbox.sh"
