modifying cleanup script to comply with hashes in the beginning of filename

This commit is contained in:
cnst
2024-08-11 14:12:54 +02:00
parent 9e6eb41b13
commit 9eb73f3147

View File

@@ -5,7 +5,7 @@
# "nix build .#packages.x86_64-linux.cleanup-boot".
# Number of generations to keep
KEEP_GENERATIONS=5
KEEP_GENERATIONS=4
# Log file for cleanup actions
LOG_FILE="/var/log/cleanup-boot.log"
@@ -29,10 +29,10 @@ set -e
log "Starting cleanup script. Keeping the latest $KEEP_GENERATIONS generations."
# List the initrd files in /boot/EFI/nixos sorted by modification time (oldest first)
mapfile -t initrd_files < <(find /boot/EFI/nixos -type f -name 'initrd-*.efi' -printf '%T@ %p\n' | sort -n)
mapfile -t initrd_files < <(find /boot/EFI/nixos -type f -name '*initrd*.efi' -printf '%T@ %p\n' | sort -n)
# List the kernel files in /boot/EFI/nixos sorted by modification time (oldest first)
mapfile -t kernel_files < <(find /boot/EFI/nixos -type f -name 'kernel-*.efi' -printf '%T@ %p\n' | sort -n)
mapfile -t kernel_files < <(find /boot/EFI/nixos -type f -name '*kernel*.efi' -printf '%T@ %p\n' | sort -n)
# Count the number of initrd and kernel files
initrd_count=${#initrd_files[@]}