[KRNL-5830] Readability and style improvements

This commit is contained in:
Michael Boelen 2016-07-31 16:28:17 +02:00
parent 0993c0a13b
commit ff38336e0b
1 changed files with 27 additions and 27 deletions

View File

@ -460,25 +460,25 @@
LogText "Test: Checking presence ${FILE}" LogText "Test: Checking presence ${FILE}"
if [ -f ${FILE} ]; then if [ -f ${FILE} ]; then
LogText "Result: file ${FILE} exists" LogText "Result: file ${FILE} exists"
FIND=`cat ${FILE}` FIND=$(wc -l < ${FILE})
if [ "${FIND}" = "" ]; then if [ "${FIND}" = "0" ]; then
LogText "Result: No reboot needed (file empty)" LogText "Result: No reboot needed (file empty)"
REBOOT_NEEDED=0 REBOOT_NEEDED=0
else else
PKGSCOUNT=`cat ${FILE} | wc -l` PKGSCOUNT=$(wc -l < {FILE})
LogText "Result: reboot is needed, related to ${PKGSCOUNT} packages" LogText "Result: reboot is needed, related to ${PKGSCOUNT} packages"
for I in ${FIND}; do for I in ${FIND}; do
LogText "Package: ${I}" LogText "Package: ${I}"
done done
REBOOT_NEEDED=1 REBOOT_NEEDED=1
fi fi
else else
LogText "Result: file ${FILE} not found" LogText "Result: file ${FILE} not found"
fi fi
# Check if /boot exists # Check if /boot exists
if [ -d /boot ]; then if [ -d /boot ]; then
LogText "Result: /boot exists, performing more tests from here" LogText "Result: /boot exists, performing more tests from here"
FIND=`ls /boot/* 2> /dev/null` FIND=$(ls /boot/* 2> /dev/null)
if [ ! "${FIND}" = "" ]; then if [ ! "${FIND}" = "" ]; then
if [ -f /boot/vmlinuz -a ! -L /boot/vmlinuz ]; then if [ -f /boot/vmlinuz -a ! -L /boot/vmlinuz ]; then
LogText "Result: found /boot/vmlinuz (not symlinked)" LogText "Result: found /boot/vmlinuz (not symlinked)"
@ -487,7 +487,7 @@
for I in `file /boot/vmlinuz-linux`; do for I in `file /boot/vmlinuz-linux`; do
if [ ${NEXTLINE} -eq 1 ]; then if [ ${NEXTLINE} -eq 1 ]; then
FINDVERSION="${I}" FINDVERSION="${I}"
else else
# Searching for the Linux kernel after the keyword 'version' # Searching for the Linux kernel after the keyword 'version'
if [ "${I}" = "version" ]; then NEXTLINE=1; fi if [ "${I}" = "version" ]; then NEXTLINE=1; fi
fi fi
@ -498,7 +498,7 @@
LogText "Result: reboot needed, as current kernel is different than the one loaded" LogText "Result: reboot needed, as current kernel is different than the one loaded"
REBOOT_NEEDED=1 REBOOT_NEEDED=1
fi fi
else else
ReportException "${TEST_NO}:1" "Can't determine kernel version on disk, need debug data" ReportException "${TEST_NO}:1" "Can't determine kernel version on disk, need debug data"
fi fi
elif [ -f /boot/vmlinuz-linux ]; then elif [ -f /boot/vmlinuz-linux ]; then
@ -512,18 +512,18 @@
if [ "${VERSION_ON_DISK}" = "${ACTIVE_KERNEL}" ]; then if [ "${VERSION_ON_DISK}" = "${ACTIVE_KERNEL}" ]; then
REBOOT_NEEDED=0 REBOOT_NEEDED=0
LogText "Result: no reboot needed, active kernel is the same version as the one on disk" LogText "Result: no reboot needed, active kernel is the same version as the one on disk"
else else
REBOOT_NEEDED=1 REBOOT_NEEDED=1
LogText "Result: reboot needed, as there is a difference between active kernel and the one on disk" LogText "Result: reboot needed, as there is a difference between active kernel and the one on disk"
fi fi
else else
LogText "Result: could not find the version on disk" LogText "Result: could not find the version on disk"
ReportException "${TEST_NO}:4" "Could not find the kernel version from /boot/vmlinux-linux" ReportException "${TEST_NO}:4" "Could not find the kernel version from /boot/vmlinux-linux"
fi fi
else else
if [ -L /boot/vmlinuz ]; then if [ -L /boot/vmlinuz ]; then
LogText "Result: found symlink of /boot/vmlinuz, skipping file" LogText "Result: found symlink of /boot/vmlinuz, skipping file"
else else
LogText "Result: /boot/vmlinuz not on disk, trying to find /boot/vmlinuz*" LogText "Result: /boot/vmlinuz not on disk, trying to find /boot/vmlinuz*"
fi fi
# Extra current kernel version and replace dashes to allow numeric sort later on # Extra current kernel version and replace dashes to allow numeric sort later on
@ -536,14 +536,14 @@
# Remove generic. and huge. for Slackware machines # Remove generic. and huge. for Slackware machines
KERNELS=`ls /boot/vmlinuz* | sed 's/vmlinuz-//' | sed 's/generic.//' | sed 's/huge.//' | sed 's/\.[a-z].*.//g' | sed 's/-[a-z].*.//g' | sed 's./boot/..' | sed 's/-/./g' | sort -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.` KERNELS=`ls /boot/vmlinuz* | sed 's/vmlinuz-//' | sed 's/generic.//' | sed 's/huge.//' | sed 's/\.[a-z].*.//g' | sed 's/-[a-z].*.//g' | sed 's./boot/..' | sed 's/-/./g' | sort -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.`
LogText "Output: ${KERNELS}" LogText "Output: ${KERNELS}"
elif [ ! `ls /boot/kernel* 2> /dev/null` = "" ]; then elif [ ! `ls /boot/kernel* 2> /dev/null` = "" ]; then
LogText "Output: Found a kernel file in /boot" LogText "Output: Found a kernel file in /boot"
# Display kernels, extract version numbers and sort them numeric per column (up to 6 numbers) # Display kernels, extract version numbers and sort them numeric per column (up to 6 numbers)
# Examples: # Examples:
# /boot/kernel-genkernel-x86_64-3.14.14-gentoo # /boot/kernel-genkernel-x86_64-3.14.14-gentoo
KERNELS=`ls /boot/kernel* | awk -F- '{ if ($2=="genkernel") { print $4 }}' | grep "^[0-9]" | sort -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.` KERNELS=`ls /boot/kernel* | awk -F- '{ if ($2=="genkernel") { print $4 }}' | grep "^[0-9]" | sort -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.`
LogText "Output: ${KERNELS}" LogText "Output: ${KERNELS}"
else else
ReportException "${TEST_NO}:2" "Can not find any vmlinuz or kernel files in /boot, which is unexpected" ReportException "${TEST_NO}:2" "Can not find any vmlinuz or kernel files in /boot, which is unexpected"
fi fi
if [ ! "${KERNELS}" = "" ]; then if [ ! "${KERNELS}" = "" ]; then
@ -557,14 +557,14 @@
if [ "${MYKERNEL}" = "${I}" ]; then if [ "${MYKERNEL}" = "${I}" ]; then
FOUND_KERNEL=1 FOUND_KERNEL=1
LogText "Result: Found ${I} (= our kernel)" LogText "Result: Found ${I} (= our kernel)"
else else
LogText "Result: Found ${I}" LogText "Result: Found ${I}"
fi fi
done done
# Check if we at least found the kernel on disk # Check if we at least found the kernel on disk
if [ ${FOUND_KERNEL} -eq 0 ]; then if [ ${FOUND_KERNEL} -eq 0 ]; then
ReportException "${TEST_NO}:3" "Could not find our running kernel on disk, which is unexpected" ReportException "${TEST_NO}:3" "Could not find our running kernel on disk, which is unexpected"
else else
# If we are not sure yet reboot it needed, but we found running kernel as last one on disk, we run latest kernel # If we are not sure yet reboot it needed, but we found running kernel as last one on disk, we run latest kernel
if [ ${REBOOT_NEEDED} -eq 2 ]; then if [ ${REBOOT_NEEDED} -eq 2 ]; then
LogText "Result: we found our kernel on disk as last entry, so seems to be up-to-date" LogText "Result: we found our kernel on disk as last entry, so seems to be up-to-date"
@ -573,24 +573,24 @@
fi fi
fi fi
fi fi
# No files in /boot # No files in /boot
else else
LogText "Result: Skipping this test, as there are no files in /boot" LogText "Result: Skipping this test, as there are no files in /boot"
fi fi
else else
LogText "Result: /boot does not exist" LogText "Result: /boot does not exist"
fi fi
# Display discovered status # Display discovered status
if [ ${REBOOT_NEEDED} -eq 0 ]; then if [ ${REBOOT_NEEDED} -eq 0 ]; then
Display --indent 2 --text "- Check if reboot is needed" --result "${STATUS_NO}" --color GREEN Display --indent 2 --text "- Check if reboot is needed" --result "${STATUS_NO}" --color GREEN
AddHP 5 5 AddHP 5 5
elif [ ${REBOOT_NEEDED} -eq 1 ]; then elif [ ${REBOOT_NEEDED} -eq 1 ]; then
Display --indent 2 --text "- Check if reboot is needed" --result "${STATUS_YES}" --color RED Display --indent 2 --text "- Check if reboot is needed" --result "${STATUS_YES}" --color RED
ReportWarning ${TEST_NO} "H" "Reboot of system is most likely needed" ReportWarning ${TEST_NO} "H" "Reboot of system is most likely needed"
AddHP 0 5 AddHP 0 5
else else
Display --indent 2 --text "- Check if reboot is needed" --result "${STATUS_UNKNOWN}" --color YELLOW Display --indent 2 --text "- Check if reboot is needed" --result "${STATUS_UNKNOWN}" --color YELLOW
fi fi
fi fi
# #