File size: 1,251 Bytes
6f509ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
# Master cleanup script for web crawler - runs both MongoDB and file cleanup

set -e  # Exit on error

echo "====================================================="
echo "          WEB CRAWLER COMPLETE CLEANUP               "
echo "====================================================="
echo

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

# Check if scripts exist
if [ ! -f "./mongo_cleanup.py" ] || [ ! -f "./file_cleanup.py" ]; then
    echo "Error: Required cleanup scripts not found in $SCRIPT_DIR"
    exit 1
fi

# Ensure scripts are executable
chmod +x ./mongo_cleanup.py
chmod +x ./file_cleanup.py

# Step 1: MongoDB cleanup
echo "Step 1: MongoDB Cleanup"
echo "----------------------"
if [ "$1" == "--force" ]; then
    python3 ./mongo_cleanup.py --force
else 
    python3 ./mongo_cleanup.py
fi

# Step 2: File cleanup
echo
echo "Step 2: File Cleanup"
echo "------------------"
if [ "$1" == "--force" ]; then
    python3 ./file_cleanup.py --force
else
    python3 ./file_cleanup.py
fi

echo
echo "====================================================="
echo "          CLEANUP PROCESS COMPLETED                  "
echo "====================================================="