#!/usr/bin/env bash
# pinn-sync 单次周期：refresh + SMB 推送（需 pinn session）
set -euo pipefail

ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
cd "$ROOT"

ENV_FILE="${NIANNIAN_CLIENT_ENV:-$ROOT/client/config/client-agent.env}"
if [[ -f "$ENV_FILE" ]]; then
  # shellcheck disable=SC1090
  set -a && source "$ENV_FILE" && set +a
fi

export NIANNIAN_HOME="${NIANNIAN_HOME:-$HOME/Library/Application Support/NianNian}"
export PYTHONPATH="$ROOT"

exec python3 -m pinn_sync run-once
