#!/bin/bash

# ============================================
# WHATSAPP SESSION CLEANUP SCRIPT
# ============================================
#
# Safe cleanup script for WhatsApp session files
# Can be run while Baileys service is active
#
# Usage:
#   ./scripts/cleanup-sessions.sh [options]
#
# Options:
#   --dry-run       Preview what would be deleted
#   --session <id>  Clean specific session only
#   --aggressive    Run aggressive cleanup
#   --verbose       Show detailed output
#   --quiet         Minimal output
#
# Examples:
#   ./scripts/cleanup-sessions.sh              # Normal cleanup
#   ./scripts/cleanup-sessions.sh --dry-run    # Preview only
#   ./scripts/cleanup-sessions.sh --verbose    # Detailed output
#
# Cron job (every day at 3 AM):
#   0 3 * * * cd /path/to/nodejs-server && ./scripts/cleanup-sessions.sh --quiet >> /var/log/cleanup.log 2>&1

# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"

# Change to project directory
cd "$PROJECT_DIR" || exit 1

# Run the Node.js script
node scripts/cleanup-sessions.js "$@"
