← back to Goldleafwallpaper
scripts/refresh-metalleaf-fleet.sh
25 lines
#!/usr/bin/env bash
# refresh-metalleaf-fleet.sh — nightly refresh of BOTH metal-leaf microsites
# (goldleafwallpaper.com + silverleafwallpaper.com) from the local dw_unified
# mirror. Each site's rebuild-and-deploy.sh rebuilds data/products.json from the
# ACTIVE RML- line, rsyncs it, restarts pm2, and verifies the live count.
#
# Scheduled by launchd com.steve.metalleaf-rml-refresh (daily 07:00 — after the
# 06:00 dw-shopify-products-sync populates the mirror). One site failing does not
# abort the other; the exit code is non-zero if EITHER fails, so launchd logs it.
set -u
# launchd starts jobs with a minimal PATH that lacks Homebrew, so the child
# rebuild-and-deploy.sh scripts fail with "node: command not found". Restore it.
export PATH="/opt/homebrew/bin:/opt/homebrew/opt/postgresql@14/bin:/usr/local/bin:/usr/bin:/bin:$PATH"
GOLD="$HOME/Projects/goldleafwallpaper/scripts/rebuild-and-deploy.sh"
SILVER="$HOME/Projects/silverleafwallpaper/scripts/rebuild-and-deploy.sh"
rc=0
echo "===== metal-leaf RML refresh $(date '+%F %T') ====="
bash "$GOLD" || { echo "GOLD refresh FAILED"; rc=1; }
bash "$SILVER" || { echo "SILVER refresh FAILED"; rc=1; }
echo "===== done (rc=$rc) ====="
exit $rc