Improve detecting kernel version on disk

Improve handling of kenrel files
/boot/vmlinuz-linux-lts
/boot/vmlinuz-linux
/boot/vmlinuz-lts
by updateing RegEx and adding elif
this corrects issue where version is identified
as 'linux' or 'lts' causing false report that a
reboot is needed
This commit is contained in:
Steve Kolenich 2020-08-10 12:27:30 -04:00
parent ec551d732d
commit f65f4d011b

View File

@ -664,6 +664,9 @@
elif [ -f ${ROOTDIR}boot/vmlinuz-linux-lts ]; then
LogText "Result: found ${ROOTDIR}boot/vmlinuz-linux-lts"
FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-linux-lts
elif [ -f ${ROOTDIR}boot/vmlinuz-lts ]; then
LogText "Result: found ${ROOTDIR}boot/vmlinuz-lts"
FOUND_VMLINUZ=${ROOTDIR}boot/vmlinuz-lts
else
# Match on /boot/vm5.3.7 or /boot/vmlinuz-5.3.7-1-default
FOUND_VMLINUZ=$(${LSBINARY} -t ${ROOTDIR}boot/vm[l0-9]* 2> /dev/null | ${HEADBINARY} -1)
@ -678,7 +681,7 @@
VERSION_ON_DISK=$(echo ${FOUND_VMLINUZ} | ${SEDBINARY} 's#^/boot/##' | ${SEDBINARY} 's/^vmlinuz-//')
LogText "Result: version derived from file name is '${VERSION_ON_DISK}'"
elif [ -f "${FOUND_VMLINUZ}" ]; then
VERSION_ON_DISK=$(echo ${FOUND_VMLINUZ} | ${SEDBINARY} 's#^/boot/##' | ${SEDBINARY} 's/^vmlinuz-//')
VERSION_ON_DISK=$(echo ${FOUND_VMLINUZ} | ${SEDBINARY} 's#^/boot/##' | ${SEDBINARY} 's/^vmlinuz-//' | ${SEDBINARY} '$s/-\?\(linux\)\?-\?\(lts\)\?//')
LogText "Result: version derived from file name is '${VERSION_ON_DISK}'"
fi