remove-old-kernels: Always say something about backup kernel

Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
This commit is contained in:
Виталий Чикунов 2022-06-26 09:27:50 +03:00
parent 185d99fade
commit 6091d09c2a

View File

@ -127,15 +127,24 @@ good_kernel=${good_kernel##* }
good_kernel_days=${good_kernel_days#(}
good_kernel_days=${good_kernel_days%%+*}
good_kernel_package=
if [ -n "$good_kernel" ] && [ "$good_kernel" != "$uname_r" ]; then
tver=${good_kernel%%-*}
trel=${good_kernel##*-}
tflv=${good_kernel#"$tver"-}
tflv=${tflv%-"$trel"}
good_kernel=kernel-image-$tflv-$tver-$trel
good_kernel_package=$(rpm -q "$good_kernel")
unset tver trel tflv
echo "Previous kernel with uptime $good_kernel_days days: $good_kernel"
if [ -n "$good_kernel" ]; then
if [ "$good_kernel" != "$uname_r" ]; then
tver=${good_kernel%%-*}
trel=${good_kernel##*-}
tflv=${good_kernel#"$tver"-}
tflv=${tflv%-"$trel"}
good_kernel=kernel-image-$tflv-$tver-$trel
good_kernel_package=$(rpm -q "$good_kernel" 2>/dev/null)
unset tver trel tflv
echo "Previous kernel with uptime $good_kernel_days days: $BRIGHT$good_kernel$NORM (backup)"
if [ -z "$good_kernel_package" ]; then
echo "${RED}Warning: Package for the backup kernel not found.$NORM"
fi
else
echo "Backup kernel is the same as booted kernel (uptime $good_kernel_days days)."
fi
else
echo "${RED}Warning: Backup kernel is not determined.$NORM"
fi
# Sort the kernels