← back to Launchd Reminders

wolf-gordon-reauth-reminder.sh

56 lines

#!/usr/bin/env bash
# One-shot reminder set on 2026-05-01: 2-week followup on the wolf_gordon_catalog
# disable inside gemini-catalog-tagger. Sends email via George (local Mac, :9850),
# then self-removes its launchd plist + this script.
set -uo pipefail

LABEL="com.steve.wolf-gordon-reauth-reminder"
PLIST="$HOME/Library/LaunchAgents/${LABEL}.plist"
LOG="$HOME/Projects/launchd-reminders/logs/wolf-gordon-reauth.log"

mkdir -p "$(dirname "$LOG")"
exec >> "$LOG" 2>&1
echo "[$(date -u +%Y-%m-%dT%H:%M:%SZ)] firing wolf-gordon-reauth reminder"

read -r -d '' BODY <<'EOF'
Two weeks ago (2026-05-01), `wolf_gordon_catalog` was disabled in
`gemini-catalog-tagger` because the Wolf Gordon CDN was returning 401 for
every swatch image (29 MB error log, 7 pm2 restarts in 147 min).

**Action items**
1. Get Wolf Gordon trade-portal credentials (or confirm DW already has them).
2. Test fetch with auth on a sample URL:
   `curl -I -H "Cookie: <auth>" https://cdn2-optimize.wolfgordon.com/production/product/swatches/act-5077.jpg?w=1200&h=1200&fm=jpg&auto=compress&fit=crop`
3. If 200, re-enable wolf_gordon_catalog in:
   - `~/Projects/Designer-Wallcoverings/shopify/scripts/gemini-catalog-tagger.js` (line 51)
   - `~/kamatera-mirror/Projects/Designer-Wallcoverings/shopify/scripts/gemini-catalog-tagger.js` (mirror)
4. `pm2 restart gemini-catalog-tagger`

**Or**: if Wolf Gordon is no longer a vendor, delete the comment + line entirely.
EOF

# Send via George — local Mac instance, NOT the Kamatera tailnet IP
PAYLOAD=$(jq -n --arg to 'steve@designerwallcoverings.com' \
                --arg subject 'Re-eval Wolf Gordon trade auth (gemini-catalog-tagger was paused 2 weeks ago)' \
                --arg body "$BODY" \
                '{to:$to, subject:$subject, body:$body}')
# Run curl on its own line so $? reflects curl's exit code, not the assignment.
# --fail makes HTTP 4xx/5xx a non-zero exit so a rejected send doesn't self-clean.
RESP=$(curl -sS --fail -X POST 'http://localhost:9850/api/send' \
  -u 'admin:DWSecure2024!' \
  -H 'Content-Type: application/json' \
  -d "$PAYLOAD" 2>&1)
RC=$?
echo "George response (rc=$RC): $RESP"

# Self-clean: unload + remove plist + remove this script.
# Don't unload-then-rm in same shell process or launchd may re-fire on next reboot.
if [ "$RC" -eq 0 ]; then
  launchctl bootout "gui/$(id -u)/$LABEL" 2>/dev/null || true
  rm -f "$PLIST"
  rm -f "$0"
  echo "self-cleaned: removed plist + script"
else
  echo "send failed; leaving plist in place — investigate then rm manually"
fi