#!/bin/bash
# setup-cron.sh - Install cron jobs for Clawdbot
# Run this once after deploying scripts to VPS

set -e

SCRIPT_DIR="/home/clawd/scripts"

echo "Setting up Clawdbot cron jobs..."

# Create cron entries
CRON_CONTENT="# Clawdbot Automated Tasks
# Health check - every 5 minutes
*/5 * * * * $SCRIPT_DIR/health-check.sh >> /var/log/clawdbot/health-check.log 2>&1

# Slack to Notion sync - every 5 minutes
*/5 * * * * $SCRIPT_DIR/slack-to-notion.sh >> /var/log/clawdbot/slack-sync.log 2>&1

# Morning brief - 6am Sydney (7pm UTC previous day for AEDT, 8pm for AEST)
# Adjust this line based on daylight savings
0 19 * * * $SCRIPT_DIR/morning-brief.sh >> /var/log/clawdbot/morning-brief.log 2>&1

# Evening brief - 6pm Sydney (7am UTC for AEDT, 8am for AEST)
# Adjust this line based on daylight savings
0 7 * * * $SCRIPT_DIR/evening-brief.sh >> /var/log/clawdbot/evening-brief.log 2>&1
"

# Create log directory
mkdir -p /var/log/clawdbot

# Install cron jobs
echo "$CRON_CONTENT" | crontab -

echo "Cron jobs installed:"
crontab -l

echo ""
echo "Log files will be in /var/log/clawdbot/"
echo "Done!"
