#!/bin/bash
OUT=/var/www/html/api/agent-linkedin-sourcing.json
HUNTER_KEY=$(grep "^HUNTER_IO_KEY=" /etc/weval/secrets.env 2>/dev/null | cut -d= -f2)
APOLLO_KEY=$(grep "^APOLLO_KEY=" /etc/weval/secrets.env 2>/dev/null | cut -d= -f2)
cat > $OUT << EOJ
{
"agent": "V61_LinkedIn_Sourcing",
"ts": "$(date -Iseconds)",
"icp_count": 39,
"icp_source": "V46 39 ICP Pharma/Banque/Retail/Public Maghreb+MENA",
"api_keys_configured": {
"hunter_io": $([[ -n "$HUNTER_KEY" ]] && echo true || echo false),
"apollo": $([[ -n "$APOLLO_KEY" ]] && echo true || echo false)
},
"action_required": "$([[ -z "$HUNTER_KEY$APOLLO_KEY" ]] && echo 'Yacine: add HUNTER_IO_KEY + APOLLO_KEY to secrets.env then sourcing auto-runs' || echo 'Ready - sourcing auto-runs on cron')",
"cron": "if keys present: daily 11:00 sourcing 5 emails/day max",
"status": "$([[ -n "$HUNTER_KEY$APOLLO_KEY" ]] && echo READY_AUTO || echo AWAITING_API_KEYS)"
}
EOJ
chown www-data:www-data $OUT 2>/dev/null
echo "linkedin sourcing configured"