From 66d7bb01037c69cde48dc529e95f28def2cb9320 Mon Sep 17 00:00:00 2001 From: Jed Reynolds Date: Mon, 21 Dec 2020 16:19:17 -0800 Subject: [PATCH] check_large_files.bash: adds little logic to determine latest kernel version--incorrectly --- check_large_files.bash | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/check_large_files.bash b/check_large_files.bash index 48abde69..384ae49f 100755 --- a/check_large_files.bash +++ b/check_large_files.bash @@ -181,7 +181,7 @@ clean_old_kernels() { # need to avoid most recent fedora kernel if [ -x /usr/bin/rpm ]; then - local kern_pkgs=( $( rpm -qa 'kernel*' | sort ) ) + local kern_pkgs=( $( rpm -qa 'kernel*' | sort -n ) ) local pkg for pkg in "${kern_pkgs[@]}"; do if [[ $pkg = kernel-tools-* ]] \ @@ -207,6 +207,13 @@ clean_old_kernels() { for pkg in "${k_series[@]}"; do debug "series $pkg" done + if (( "${#k_series[@]}" > 1 )); then + local i=0 + # lets try and avoid the last item assuming that is the most recent + for i in $( seq 0 $(( ${#k_series[@]} - 2 )) ); do + debug "item $i is ${k_series[$i]}" + done + fi fi set +x if (( ${#selected_k[@]} < 1 )); then @@ -273,7 +280,8 @@ kernel_files=() survey_kernel_files() { debug "Surveying Kernel files" mapfile -t kernel_files < <(ls /boot/* /lib/modules/* 2>/dev/null) - totals[b]=$(du -hc "$kernel_files" | awk '/total/{print $1}') + # totals[b]=$(du -hc "$kernel_files" | awk '/total/{print $1}') + local boot_u= } # Find core files