Compare commits

..

No commits in common. "62d69bac03b1dae2988649427304f53bc9f573fe" and "6794061edd5dced40c91132b8a9ee70895f7d000" have entirely different histories.

2 changed files with 26 additions and 24 deletions

View File

@ -15,7 +15,7 @@ For more detailed information about the script's workings, refer to the comments
To use this script, clone this repository to your local system and run the script with the necessary arguments. The command should be structured as follows: To use this script, clone this repository to your local system and run the script with the necessary arguments. The command should be structured as follows:
```bash ```bash
bash cleanup.sh BACKUP_HASH bash cleanup.sh BACKUP_HASH TRIGGER_DIRECTORY
``` ```
Replace ```BACKUP_HASH``` and ```TRIGGER_DIRECTORY``` with your actual values. Replace ```BACKUP_HASH``` and ```TRIGGER_DIRECTORY``` with your actual values.

View File

@ -12,21 +12,20 @@ else
exit 1 exit 1
fi fi
# Define trigger directory argument as TRIGGER_DIR
TRIGGER_DIR="$2"
# Loop through all subdirectories in the main directory # Loop through all subdirectories in the main directory
for SUBDIR in "$MAIN_DIRECTORY"/*; do for SUBDIR in "$MAIN_DIRECTORY"/*; do
# Only proceed if it is a directory # Only proceed if it is a directory
if [ -d "$SUBDIR" ]; then if [ -d "$SUBDIR" ]; then
echo "Validating directory: $SUBDIR" echo "Validating directory: $SUBDIR"
# Only proceed if the specified trigger directory does not exist within the subdirectory
# Call the Python script for validation FULL_TRIGGER_DIR_PATH="$SUBDIR/$TRIGGER_DIR"
python ../directory-validator/directory-validator.py "$SUBDIR" --validate if [ ! -d "$FULL_TRIGGER_DIR_PATH" ]; then
VALIDATION_STATUS=$?
if [ $VALIDATION_STATUS -eq 0 ]; then
echo "Validation: ok"
else
echo "Validation: error" echo "Validation: error"
echo "Missing directory: $FULL_TRIGGER_DIR_PATH"
# Display the subdirectory contents # Display the subdirectory contents
echo "Contents of subdirectory: $SUBDIR" echo "Contents of subdirectory: $SUBDIR"
ls "$SUBDIR" ls "$SUBDIR"
@ -40,6 +39,9 @@ for SUBDIR in "$MAIN_DIRECTORY"/*; do
echo "Deleting subdirectory: $SUBDIR" echo "Deleting subdirectory: $SUBDIR"
rm -vrf "$SUBDIR" rm -vrf "$SUBDIR"
fi fi
else
echo "Validation: ok"
echo "$SUBDIR contains $FULL_TRIGGER_DIR_PATH."
fi fi
fi fi
done done