Merge pull request 'Add some fixes in retention-helper.sh' (#7) from retention-helper-fixes into main

Reviewed-on: #7
This commit is contained in:
Thomas Gebert 2024-10-08 08:45:07 +00:00
commit 55546f416c

View File

@ -42,7 +42,7 @@ HELP
}
get_atime_of_file() {
stat --format=%X "${1}"
stat --format=%X "${1}" 2> /dev/null
}
get_xattr_of_file() {
@ -50,17 +50,20 @@ get_xattr_of_file() {
}
find_files_with_atime() {
for FILE in $(find "${DIRECTORY}" -type f); do
while read -r FILE; do
ATIME_FILE=$(get_atime_of_file "${FILE}")
if [ "${ATIME_FILE}" == "" ]; then
continue
fi
if [ ${ATIME_FILE} -ge ${ATIME_SEARCH} ]; then
echo "${FILE}"
fi
done
done <<< $(find "${DIRECTORY}" -type f)
}
find_files_with_retention() {
for FILE in $(find "${DIRECTORY}" -type f); do
while read -r FILE; do
RETENTION_FILE=$(get_xattr_of_file "${FILE}" "trusted.worm.attr" | grep -o '[0-9]\+$')
if [ "${RETENTION_FILE}" == "" ]; then
continue
@ -69,7 +72,7 @@ find_files_with_retention() {
if [ ${RETENTION_FILE} -eq ${RETENTION_SEARCH} ]; then
echo "${FILE}"
fi
done
done <<< $(find "${DIRECTORY}" -type f)
}
@ -86,13 +89,16 @@ set_atime() {
show_atime_retention() {
for FILE in $(find "${DIRECTORY}" -type f); do
while read -r FILE; do
ATIME=$(get_atime_of_file "${FILE}")
if [ "${ATIME}" == "" ]; then
continue
fi
TRUSTED_WORM_ATTR=$(get_xattr_of_file "${FILE}" "trusted.worm.attr" | grep -o '[0-9]\+$')
echo "${FILE}"
echo " atime: $(date --date=@${ATIME}) || ${ATIME}"
echo " trusted.worm.attr: ${TRUSTED_WORM_ATTR}"
done
done <<< $(find "${DIRECTORY}" -type f)
}
################################################################################