From: Valentin Vidic Date: Fri, 7 Nov 2008 09:34:17 +0000 (+0100) Subject: Check if reboot to latest kernel is required. X-Git-Tag: debian/5.0.0~76 X-Git-Url: http://ftp.carnet.hr/pub/carnet-debian/scm?a=commitdiff_plain;h=34fae0d4853ef205525f1fc864652e3181117160;p=carnet-upgrade.git Check if reboot to latest kernel is required. --- diff --git a/src/functions.sh b/src/functions.sh index 66021e4..970d3db 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -405,7 +405,7 @@ check_grsec_kernel () { return 0 fi - if [ "$ver" = "${ver#2.6.2[4-9]}" ]; then + if [ "$ver" = "${ver#2.6.2[4-9]}" ] || reboot_required; then # kernel too old notice " Prije prelaska na Debian Etch potrebno je napraviti nadogradnju na najnoviji grsec kernel. @@ -421,6 +421,53 @@ Nakon toga ponovno pozovite ovu skriptu." fi } +# check if the latest kernel is booted +reboot_required () { + local default_kernel kernel_package running_release running_version + + default_kernel=$( lilo -t -v 2>/dev/null \ + | grep -B3 '[*]$' \ + | sed -n -e '/^Boot image: / { s///p; q; }' ) + + if [ -z "$default_kernel" ]; then + log "Could not find default kernel" + return 1 + fi + + log "Default kernel image: $default_kernel" + + if [ ! -e "$default_kernel" ]; then + log "Default kernel image doesn't exist!?" + return 1 + fi + + kernel_package=$( dpkg -S $default_kernel | cut -d: -f 1 ) + + if [ -z "$kernel_package" ]; then + log "Default kernel not installed from a package" + return 1 + fi + + log "Default kernel package: $kernel_package" + + if [ "$kernel_package" != "kernel-2.6-cn" ]; then + log "Default kernel package is not kernel-2.6-cn" + return 1 + fi + + running_release=$( uname -r ) + running_version=$( uname -v ) + log "Running kernel: $running_release $running_version" + + if grep -q "$running_release .* $running_version" $default_kernel; then + log "Latest kernel version is running." + return 1 + else + log "Reboot to latest version required." + return 0 + fi +} + upgrade () { local i to_install packages case "$1" in