25 lines
979 B
Bash
25 lines
979 B
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
REMOTE_DIR="${CAIWU_REMOTE_DIR:-/opt/caiwuxitong}"
|
|
LOCK_FILE="${CAIWU_UPSTREAM_LOCK:-/run/caiwu-upstream-sync.lock}"
|
|
case "${1:-}" in
|
|
jushuitan:sync-shipping|store-receipt:order-match:sync|store-receipt:product-cost:sync|order-data:warm-shop-candidates) ;;
|
|
*) echo 'Unsupported finance batch command' >&2; exit 64 ;;
|
|
esac
|
|
cd "$REMOTE_DIR"
|
|
exec 9>"$LOCK_FILE"
|
|
if ! flock -w "${CAIWU_BATCH_LOCK_WAIT:-1800}" 9; then
|
|
echo 'Upstream synchronization is busy; no batch container started' >&2
|
|
exit 75
|
|
fi
|
|
image="$(docker inspect caiwu_app --format '{{.Config.Image}}')"
|
|
case "$image" in
|
|
caiwu_akaunting:*) IMAGE_TAG="${image#*:}" ;;
|
|
*) echo 'Unsupported active finance image; no batch container started' >&2; exit 65 ;;
|
|
esac
|
|
RUN_MIGRATIONS=0
|
|
export IMAGE_TAG RUN_MIGRATIONS
|
|
# Holds the same lock as scheduled sync and release activation for the full job.
|
|
docker compose -f compose.jiangling.yml --profile batch run --rm -T --no-deps batch "$@"
|