refactor: Rename cleaner.sh and keymanager.sh scripts
Renames 'clean.sh' to 'cleaner.sh' and 'hdb_keymanager.sh' to 'keymanager.sh' for consistency. Updates corresponding file paths in 'packages.conf'.
This commit is contained in:
30
cleaner.sh
Normal file
30
cleaner.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Version: 1.1.0
|
||||
|
||||
# Check if any arguments were provided
|
||||
if [ "$#" -eq 0 ]; then
|
||||
echo "Usage: $0 <retention_days>:<path> [<retention_days>:<path> ...]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Loop through each argument provided
|
||||
for ARG in "$@"; do
|
||||
# Split the argument at the first colon
|
||||
IFS=':' read -r RETENTION_DAYS TARGET_DIR <<< "$ARG"
|
||||
|
||||
# Validate that both a retention period and a path were provided
|
||||
if [ -z "$RETENTION_DAYS" ] || [ -z "$TARGET_DIR" ]; then
|
||||
echo "Invalid format for argument: $ARG. Please use the format <retention_days>:<path>"
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "Starting cleanup of files older than $RETENTION_DAYS days in $TARGET_DIR..."
|
||||
|
||||
# Use find to locate and delete files, handling potential errors
|
||||
find "$TARGET_DIR" -type f -mtime +"$RETENTION_DAYS" -delete -print || echo "Could not process $TARGET_DIR. Check permissions."
|
||||
|
||||
echo "Cleanup complete for $TARGET_DIR."
|
||||
echo "--------------------------------------------------"
|
||||
done
|
||||
|
||||
echo "All cleanup tasks finished."
|
||||
Reference in New Issue
Block a user