#!/usr/bin/env bash # Insert / update the Torob Product API v3 proxy on a storefront nginx site. # Torob POSTs https://{host}/torob_api/v3/products (JWT aud = shop host). set -euo pipefail HOST="${1:-}" API_HOST="${MESHKEE_API_HOST:-api.meshkee.com}" if [[ -z "$HOST" ]]; then echo "usage: patch-nginx-torob.sh " >&2 exit 1 fi NGINX_AVAILABLE="/etc/nginx/sites-available/$HOST" if [[ ! -f "$NGINX_AVAILABLE" ]]; then echo "missing nginx site for $HOST" >&2 exit 1 fi PATH_LOC="/torob_api/v3/products" if grep -qF "location = ${PATH_LOC}" "$NGINX_AVAILABLE"; then echo "already present: ${PATH_LOC}" exit 0 fi block="$(cat <"$tmp" mv "$tmp" "$NGINX_AVAILABLE" echo "added: ${PATH_LOC}" nginx -t systemctl reload nginx echo "patched nginx Torob product API location for $HOST"