Try to get default kernel from lilo or grub config.
authorValentin Vidic <Valentin.Vidic@CARNet.hr>
Tue, 17 Mar 2009 14:45:53 +0000 (15:45 +0100)
committerValentin Vidic <Valentin.Vidic@CARNet.hr>
Tue, 17 Mar 2009 14:45:53 +0000 (15:45 +0100)
src/functions.sh

index c51c2d2..1ba1323 100644 (file)
@@ -487,9 +487,22 @@ Nakon toga ponovno pozovite ovu skriptu."
 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; }' )
+  # try to get default kernel from lilo
+  if type lilo >/dev/null 2>&1; then
+      default_kernel=$( lilo -t -v 2>/dev/null \
+                        | grep -B3 '[*]$' \
+                        | sed -n -e '/^Boot image: / { s///p; q; }' )
+  fi
+
+  # fallback to grub if lilo not installed
+  if [ -z "$default_kernel" -a -r "/boot/grub/menu.lst" ]; then
+      default_kernel=$( awk '
+           $1 == "default" { default = $2; 
+                             if (default != /^[[:digit:]]+$/) { exit } }
+           $1 == "title" { title+=1 }
+           $1 == "kernel" && title==default+1 { print $2; exit }' \
+           /boot/grub/menu.lst 2>/dev/null )
+  fi
 
   if [ -z "$default_kernel" ]; then
       log "Could not find default kernel"