37 lines
1.3 KiB
Bash
Executable File
37 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# This script cleans all VK-related directories and logs
|
|
# It removes all files from categories, albums, products and logs directories
|
|
|
|
# Get the directory where this script is located
|
|
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
|
# Load constants and functions
|
|
source $SCRIPT_DIR/constants.sh
|
|
source $SCRIPT_DIR/functions.sh
|
|
|
|
# Initialize logging system
|
|
setup_logging
|
|
|
|
# Ensure we clean up properly even if script is interrupted
|
|
trap 'cleanup 1' HUP INT QUIT TERM
|
|
|
|
# Begin cleanup process
|
|
echo "$(timestamp) [INFO] Starting cleanup process" >> "$LOG_FILE"
|
|
|
|
# Clean VK content directories
|
|
echo "$(timestamp) [INFO] Cleaning VK directories" >> "$LOG_FILE"
|
|
# Remove category files
|
|
echo "$(timestamp) [INFO] Removing category files" >> "$LOG_FILE"
|
|
echo "rm -f $VK_CATEGORIES_PATH/*" && rm -rf $VK_CATEGORIES_PATH/*
|
|
# Remove album files
|
|
echo "$(timestamp) [INFO] Removing album files" >> "$LOG_FILE"
|
|
echo "rm -f $VK_ALBUMS_PATH/*" && rm -rf $VK_ALBUMS_PATH/*
|
|
# Remove product files
|
|
echo "$(timestamp) [INFO] Removing product files" >> "$LOG_FILE"
|
|
echo "rm -f $VK_PRODUCTS_PATH/*" && rm -rf $VK_PRODUCTS_PATH/*
|
|
# Clean logs directory
|
|
echo "$(timestamp) [INFO] Cleaning logs directory" >> "$LOG_FILE"
|
|
echo "rm -f $LOG_DIR/*" && rm -rf $LOG_DIR/*
|
|
|
|
echo "$(timestamp) [INFO] Cleanup completed successfully" >> "$LOG_FILE"
|
|
cleanup 0 |