Magellan Linux

Diff of /tags/grubby-8_40_20170706/new-kernel-pkg

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC revision 924 by niro, Wed Oct 28 13:26:45 2009 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Id$
3  #  #
4    # new-kernel-pkg
5  # Invoked upon installation or removal of a kernel package, the following  # Invoked upon installation or removal of a kernel package, the following
6  # tasks are/can be done here:  # tasks are/can be done here:
7  # creation/removal of initrd  # creation/removal of initrd
8  # run of depmod/removal of depmod generated files  # run of depmod/removal of depmod generated files
9  # addition/removal of kernel images from grub/lilo configuration (via grubby)  # addition/removal of kernel images from grub/lilo configuration (via grubby)
10  #  #
11  # Copyright (C) 2002-2005 Red Hat, Inc.  # Copyright 2002-2008 Red Hat, Inc.  All rights reserved.
 #  
12  # modified for Magellan-Linux by Niels Rogalla <niro@magellan-linux.de>  # modified for Magellan-Linux by Niels Rogalla <niro@magellan-linux.de>
13  #  #
14    # This program is free software; you can redistribute it and/or modify
15    # it under the terms of the GNU General Public License as published by
16    # the Free Software Foundation; either version 2 of the License, or
17    # (at your option) any later version.
18    #
19    # This program is distributed in the hope that it will be useful,
20    # but WITHOUT ANY WARRANTY; without even the implied warranty of
21    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22    # GNU General Public License for more details.
23    #
24    # You should have received a copy of the GNU General Public License
25    # along with this program.  If not, see <http://www.gnu.org/licenses/>.
26    #
27    
28  PATH=/sbin:/bin:$PATH  PATH=/sbin:/bin:$PATH
29    
# Line 18  lilo=/sbin/lilo Line 32  lilo=/sbin/lilo
32  # some defaults that are sane for most arches  # some defaults that are sane for most arches
33  kernelName=kernel  kernelName=kernel
34    
35  if [ -x ./grubby ]; then  if [ -x ./grubby ]
36      grubby=./grubby  then
37     grubby=./grubby
38  else  else
39      grubby=/sbin/grubby   grubby=/sbin/grubby
40  fi  fi
41    
42  [ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel  [ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel
# Line 33  grubConfig="" Line 48  grubConfig=""
48    
49  ARCH=$(uname -m)  ARCH=$(uname -m)
50    
51  if [ $ARCH = 'ia64' ]; then  if [[ ${ARCH} = ia64 ]]
52      liloConfig=/boot/efi/EFI/redhat/elilo.conf  then
53      bootPrefix=/boot/efi/EFI/redhat   liloConfig=/boot/efi/EFI/redhat/elilo.conf
54      liloFlag=elilo   bootPrefix=/boot/efi/EFI/redhat
55      isx86=""   liloFlag=elilo
56  elif [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then   isx86=""
57      liloConfig=/etc/yaboot.conf  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
58      bootPrefix=/boot  then
59      lilo=/sbin/ybin   liloConfig=/etc/yaboot.conf
60      liloFlag=yaboot   bootPrefix=/boot
61      runLilo="yes"   lilo=/sbin/ybin
62      isx86=""   liloFlag=yaboot
63  elif [ $ARCH = 'sparc' -o $ARCH = 'sparc64' ]; then   runLilo="yes"
64      liloConfig=/etc/silo.conf   isx86=""
65      bootPrefix=/boot  elif [[ ${ARCH} = sparc ]] || [[ ${ARCH} = sparc64 ]]
66      liloFlag=silo  then
67      lilo=/sbin/silo   liloConfig=/etc/silo.conf
68      isx86=""   bootPrefix=/boot
69  elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then   liloFlag=silo
70      liloConfig=/etc/zipl.conf   lilo=/sbin/silo
71      bootPrefix=/boot   isx86=""
72      liloFlag=zipl  elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
73      lilo=/sbin/zipl  then
74      runLilo="yes"   liloConfig=/etc/zipl.conf
75      isx86=""   bootPrefix=/boot
76     liloFlag=zipl
77     lilo=/sbin/zipl
78     runLilo="yes"
79     isx86=""
80  else  else
81      # this leaves i?86 and x86_64   # this leaves i?86 and x86_64
82      liloConfig=/etc/lilo.conf   liloConfig=/etc/lilo.conf
83      grubConfig=/boot/grub/grub.conf   grubConfig=/boot/grub/grub.conf
84      bootPrefix=/boot   bootPrefix=/boot
85      liloFlag=lilo   liloFlag=lilo
86      isx86="yes"   isx86="yes"
87  fi  fi
88    
89  mode=""  mode=""
# Line 78  package="" Line 97  package=""
97  mbkernel=""  mbkernel=""
98  mbargs=""  mbargs=""
99    
100  usage() {  usage()
101      echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd]" >&2  {
102      echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2   echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd]" >&2
103      echo "       [--kernel-args=<args>] [--banner=<banner>]" >&2   echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
104      echo "       [--multiboot=multiboot] [--mbargs=mbargs]" >&2   echo "       [--kernel-args=<args>] [--remove-args=<args>]" >&2
105      echo "       [--make-default] <--install | --remove> <kernel-version>" >&2   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2
106      echo "       (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2   echo "       [--mbargs=mbargs] [--make-default]" >&2
107      exit 1   echo "       <--install | --remove | --update> <kernel-version>" >&2
108     echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
109     exit 1
110  }  }
111    
112  install() {  install()
113      # XXX kernel should be able to be specified also (or work right on ia64)  {
114      if [ ! -f $bootPrefix/$kernelName-$version ] ; then   # XXX kernel should be able to be specified also (or work right on ia64)
115   [ -n "$verbose" ] && echo "kernel for $version does not exist, not running grubby"   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]
116   return   then
117      fi   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
118         return
119      INITRD=""   fi
120      if [ -f $initrdfile ]; then  
121   [ -n "$verbose" ] && echo "found $initrdfile and using it with grubby"   INITRD=""
122   INITRD="--initrd $initrdfile"   if [ -f ${initrdfile} ]
123      fi   then
124     [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
125      # FIXME: is this a good heuristic to find out if we're on iSeries?   INITRD="--initrd ${initrdfile}"
126      if [ -d /proc/iSeries ]; then   fi
127   [ -n "$verbose" ] && echo "On an iSeries, just making img file"  
128   if [ -z $initrdfile  ]; then   # FIXME: is this a good heuristic to find out if we're on iSeries?
129      [ -n "$verbose" ] && echo "No initrd, just adding system map"   if [ -d /proc/iSeries ]
130      /sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinitrd-$version   then
131     [[ -n ${verbose} ]] && echo "On an iSeries, just making img file"
132     if [[ -z ${initrdfile} ]]
133     then
134     [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
135     /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version}
136     else
137     /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version}
138     /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null
139     rm ${bootPrefix}/vmlinux.sm-${version}
140     fi
141     return
142     fi
143    
144     # get the root filesystem to use
145     rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)
146    
147     if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
148     then
149     [[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf"
150     cfgLilo=""
151     fi
152    
153     if [[ -n ${cfgGrub} ]]
154     then
155     [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
156    
157     if [[ -n ${banner} ]]
158     then
159     title="${banner} (${version})"
160     elif [ -f /etc/mageversion ]
161     then
162     title="Magellan Linux $(< /etc/mageversion) (${version})"
163     else
164     title="Magellan Linux (${version})"
165     fi
166     ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \
167     ${INITRD} --copy-default ${makedefault} --title "${title}" \
168     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
169     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
170   else   else
171      /sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinux.sm-$version   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
172      /sbin/addRamDisk $initrdfile $bootPrefix/System.map-$version $bootPrefix/vmlinux.sm-$version $bootPrefix/vmlinitrd-$version 2>/dev/null   fi
173      rm $bootPrefix/vmlinux.sm-$version  
174   fi   if [[ -n ${cfgLilo} ]]
175   return   then
176      fi   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
177    
178      # get the root filesystem to use; if it's on a label make sure it's   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \
179      # been configured. if not, get the root device from mount   --copy-default ${makedefault} --title ${version} \
180      rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
181      short=$(echo $rootdevice | cut -d= -f1)   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \
182      if [ "$short" == "LABEL" ]; then   --${liloFlag}
183   label=$(echo $rootdevice | cut -d= -f2 |head -n 1)  
184   device=$(echo "showlabels" | /sbin/nash  --force --quiet |   if [[ -n ${runLilo} ]]
185   awk '$2 == "'$label'" {print $1}')   then
186   if [ -z "$device" ]; then   [[ -n ${verbose} ]] && echo "running ${lilo}"
187      rootdevice=$(mount | awk '$3 == "/" { print $1 }')   if [ ! -x $lilo ]
188   fi   then
189      fi   [[ -n ${verbose} ]] && echo "${lilo} does not exist"
190     else
191      if [ -n "$mbkernel" ]; then   ${lilo} > /dev/null
192   mb="--add-multiboot=$mbkernel"   fi
193   if [ -n "$mbargs" ]; then   fi
     mb="$mb --mbargs=$mbargs"  
  fi  
  [ -n "$verbose" ] && echo "multiboot specified, not updating lilo.conf"  
  cfgLilo=""  
     fi  
   
     if [ -n "$cfgGrub" ]; then  
  [ -n "$verbose" ] && echo "adding $version to $grubConfig"  
   
  if [ -n "$banner" ]; then  
             title="$banner ($version)"  
  elif [ -f /etc/mageversion ]; then  
     title="Magellan Linux $(< /etc/mageversion) ($version)"  
194   else   else
195      title="Magellan Linux ($version)"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
196     fi
197    }
198    
199    remove()
200    {
201     # FIXME: is this a good heuristic to find out if we're on iSeries?
202     if [ -d /proc/iSeries ]
203     then
204     [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
205     rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null
206     return
207   fi   fi
  /sbin/grubby --add-kernel=$bootPrefix/$kernelName-$version $INITRD    \  
      --copy-default $makedefault $mb --title "$title"    \  
      --args="root=$rootdevice $kernargs"    \  
      --remove-kernel="TITLE=$title"                  
     else  
  [ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"  
     fi  
   
     if [ -n "$cfgLilo" ]; then  
  [ -n "$verbose" ] && echo "adding $version to $liloConfig"  
   
  /sbin/grubby --add-kernel=$bootPrefix/$kernelName-$version $INITRD    \  
      --copy-default $makedefault --title $version    \  
      --args="root=$rootdevice $kernargs"    \  
      --remove-kernel="TITLE=$version"    \  
      --$liloFlag  
   
  if [ -n "$runLilo" ]; then  
     [ -n "$verbose" ] && echo "running $lilo"  
     if [ ! -x $lilo ] ; then  
  [ -n "$verbose" ] && echo "$lilo does not exist"  
     else  
  $lilo > /dev/null  
     fi  
  fi  
     else  
  [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"  
     fi  
208    
209     if [[ -n ${cfgGrub} ]]
210     then
211     [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
212     ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version}
213     else
214     [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
215     fi
216    
217     if [[ -n ${cfgLilo} ]]
218     then
219     [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
220     ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version}    \
221     --${liloFlag}
222    
223     if [[ -n ${runLilo} ]]
224     then
225     [[ -n ${verbose} ]] && echo "running ${lilo}"
226     if [ ! -x ${lilo} ]
227     then
228     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
229     else
230     ${lilo} > /dev/null
231     fi
232     fi
233     else
234     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
235     fi
236  }  }
237    
238  remove() {  update()
239      # FIXME: is this a good heuristic to find out if we're on iSeries?  {
240      if [ -d /proc/iSeries ]; then   if [[ -n ${cfgGrub} ]]
241   [ -n "$verbose" ] && echo "On an iSeries, remove img file"   then
242   rm -f $bootPrefix/$kernelName-$version.img 2>/dev/null   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
243   return   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \
244      fi   ${kernargs:+--args="${kernargs}"} \
245     ${removeargs:+--remove-args="${removeargs}"}
246      if [ -n "$cfgGrub" ]; then   else
247   [ -n "$verbose" ] && echo "removing $version from $grubConfig"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
248   /sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version   fi
249      else  
250   [ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"   if [[ -n ${cfgLilo} ]]
251      fi   then
252     [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
253      if [ -n "$cfgLilo" ]; then   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \
254   [ -n "$verbose" ] && echo "removing $version from $liloConfig"   ${kernargs:+--args="${kernargs}"} \
255   /sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version    \   ${removeargs:+--remove-args="${removeargs}"} \
256       --$liloFlag   --${liloFlag}
257    
258   if [ -n "$runLilo" ]; then   if [[ -n ${runLilo} ]]
259      [ -n "$verbose" ] && echo "running $lilo"   then
260      if [ ! -x $lilo ] ; then   [[ -n ${verbose} ]] && echo "running ${lilo}"
261   [ -n "$verbose" ] && echo "$lilo does not exist"   if [ ! -x ${lilo} ]
262      else   then
263   $lilo > /dev/null   [[ -n ${verbose} ]] && echo "${lilo} does not exist"
264      fi   else
265   fi   ${lilo} > /dev/null
266      else   fi
267   [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"   fi
268      fi   else
269     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
270     fi
271  }  }
272    
273  mkinitrd() {  mkinitrd()
274      [ -n "$verbose" ] && echo "creating initrd $initrdfile using $version"  {
275      /sbin/mkinitrd --allow-missing -f $initrdfile $version   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
276      rc=$?   /sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}
277      if [ $rc != 0 ]; then   rc=$?
278   echo "mkinitrd failed" >&2   if [ ${rc} != 0 ]
279   exit 1   then
280      fi   echo "mkinitrd failed" >&2
281     exit 1
282     fi
283  }  }
284    
285  rminitrd() {  rminitrd()
286      [ -n "$verbose" ] && echo "removing initrd $initrdfile"  {
287      [ -f $initrdfile ] && rm -f $initrdfile   [[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}"
288     [ -f ${initrdfile} ] && rm -f ${initrdfile}
289  }  }
290    
291  doDepmod() {  doDepmod()
292      [ -n "$verbose" ] && echo "running depmod for $version"  {
293      depmod -ae -F /boot/System.map-$version $version   [[ -n ${verbose} ]] && echo "running depmod for ${version}"
294     depmod -ae -F /boot/System.map-${version} ${version}
295  }  }
296    
297  doRmmoddep() {  doRmmoddep()
298      [ -n "$verbose" ] && echo "removing modules.dep info for $version"  {
299      [ -d /lib/modules/$version ] && rm -f /lib/modules/$version/modules.*       [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
300     [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*
301  }  }
302    
303    
304  while [ $# -gt 0 ]; do  while [ $# -gt 0 ]
305      case $1 in  do
306   --mkinitrd)   case $1 in
307      initrd="make"   --mkinitrd)
308      ;;   initrd="make"
309     ;;
310   --rminitrd)  
311      initrd="remove"   --rminitrd)
312      ;;   initrd="remove"
313     ;;
314   --initrdfile*)  
315      if echo $1 | grep '=' >/dev/null ; then   --initrdfile*)
316       initrdfile=`echo $1 | sed 's/^--initrdfile=//'`   if echo $1 | grep '=' >/dev/null
317      else   then
318   initrdfile=$2   initrdfile=$(echo $1 | sed 's/^--initrdfile=//')
319   shift   else
320      fi       initrdfile=$2
321      ;;   shift
322     fi
323   --kernel-args*)   ;;
324      if echo $1 | grep '=' >/dev/null ; then  
325       kernargs=`echo $1 | sed 's/^--kernel-args=//'`   --kernel-args*)
326      else   if echo $1 | grep '=' >/dev/null
327   kernargs=$2   then
328   shift   kernargs=$(echo $1 | sed 's/^--kernel-args=//')
329      fi       else
330      ;;   kernargs=$2
331     shift
332   --banner*)   fi
333      if echo $1 | grep '=' >/dev/null ; then   ;;
334       banner=`echo $1 | sed 's/^--banner=//'`  
335      else   --remove-args*)
336   banner=$2   if echo $1 | grep '=' >/dev/null
337   shift   then
338      fi       removeargs=$(echo $1 | sed 's/^--remove-args=//')
339      ;;   else
340     removeargs=$2
341   --multiboot*)   shift
342      if echo $1 |grep '=' >/dev/null; then   fi
343   mbkernel=`echo $1 | sed 's/^--multiboot=//'`   ;;
344      else  
345   # can't really support having an optional second arg here   --banner*)
346   # sorry!   if echo $1 | grep '=' >/dev/null
347   mbkernel="/boot/xen.gz"   then
348      fi   banner=$(echo $1 | sed 's/^--banner=//')
349      ;;   else
350     banner=$2
351   --mbargs*)   shift
352      if echo $1 |grep '=' >/dev/null; then   fi
353   mbargs=`echo $1 | sed 's/^--mbargs=//'`   ;;
354      else  
355   mbargs=$2   --multiboot*)
356   shift   if echo $1 |grep '=' >/dev/null
357      fi   then
358      ;;   mbkernel=$(echo $1 | sed 's/^--multiboot=//')
359     else
360   --depmod)   # can't really support having an optional second arg here
361      moddep="make"   # sorry!
362      ;;   mbkernel="/boot/xen.gz"
363     fi
364   --rmmoddep)   ;;
365      moddep="remove"  
366      ;;   --mbargs*)
367     if echo $1 |grep '=' >/dev/null
368   --make-default)   then
369      makedefault="--make-default"   mbargs=$(echo $1 | sed 's/^--mbargs=//')
370      ;;   else
371     mbargs="$2"
372   --package)   shift
373      if echo $1 | grep '=' >/dev/null ; then   fi
374       package=`echo $1 | sed 's/^--package=//'`   ;;
375      else  
376   package=$2   --depmod)
377   shift   moddep="make"
378      fi       ;;
379      ;;  
380     --rmmoddep)
381   -v)   moddep="remove"
382      verbose=-v   ;;
383      ;;  
384     --make-default)
385   *)   makedefault="--make-default"
386      if [ -z "$mode" ]; then   ;;
387   mode=$1  
388      elif [ -z "$version" ]; then   --package)
389   version=$1   if echo $1 | grep '=' >/dev/null
390      else   then
391   usage   package=$(echo $1 | sed 's/^--package=//')
392      fi   else
393      ;;   package=$2
394      esac   shift
395     fi
396     ;;
397    
398     -v)
399     verbose=-v
400     ;;
401    
402     *)
403     if [[ -z ${mode} ]]
404     then
405     mode=$1
406     elif [[ -z ${version} ]]
407     then
408     version=$1
409     else
410     usage
411     fi
412     ;;
413     esac
414    
415      shift   shift
416  done  done
417    
418  # make sure the mode is valid  # make sure the mode is valid
419  if [ "$mode" != "--install" -a "$mode" != "--remove" ] ; then  if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]]
420      usage  then
421     usage
422  fi  fi
423    
424  if [ -z "$version" ]; then  if [[ -z ${version} ]]
425      usage  then
426     usage
427  fi  fi
428    
429  if [ "$mode" != "--install" -a "$makedefault" ]; then  if [ "${mode}" != "--install" -a "${makedefault}" ]
430      usage  then
431     usage
432  fi  fi
433    
434  # make sure that /dev/loop exist  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
 [[ ! -e /dev/loop ]] && modprobe loop  
   
 kernelmajor=`echo $kernel | cut -d . -f 1,2`  
435    
436  # kernel image for 2.4 is vmlinux  # kernel image for 2.4 is vmlinux
437  if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then  if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
438    if [ "$kernelmajor" == "2.4" ]; then  then
439        kernelName=vmlinux   if [[ ${kernelmajor} = 2.4 ]]
440    fi   then
441     kernelName=kernel
442     fi
443  fi  fi
444    
   
445  # set the initrd file based on arch; ia64 is the only currently known oddball  # set the initrd file based on arch; ia64 is the only currently known oddball
446  if [ -z "$initrdfile" ]; then  if [[ -z ${initrdfile} ]]
447      if [ `uname -m` = "ia64" ]; then  then
448   initrdfile="/boot/efi/EFI/redhat/initrd-$version.img"   INITRD_NAME_PREFIX="initrd"
449      else  
450   initrdfile="/boot/initrd-$version.img"   if [[ $(uname -m) = ia64 ]]
451      fi   then
452     initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img"
453     else
454     initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img"
455     fi
456  fi  fi
457  [ -n "$verbose" ] && echo "initrdfile is $initrdfile"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
458    
459  # set this as the default if we have the package and it matches  # set this as the default if we have the package and it matches
460  if [ "$mode" == "--install" -a "$UPDATEDEFAULT" == "yes" -a -n "$package" -a -n "$DEFAULTKERNEL" -a "$package" == "$DEFAULTKERNEL" ]; then  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&
461      makedefault="--make-default"   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]
462      [ -n "$verbose" ] && echo "making it the default based on config"  then
463     makedefault="--make-default"
464     [[ -n ${verbose} ]] && echo "making it the default based on config"
465  fi  fi
466    
467  if [ "$moddep" == "make" ]; then  if [[ ${moddep} = make ]]
468      doDepmod  then
469  elif [ "$moddep" == "remove" ]; then   doDepmod
470      doRmmoddep  elif [[ ${moddep} = remove ]]
471    then
472     doRmmoddep
473  fi  fi
474    
475  if [ "$initrd" == "make" ]; then  if [[ ${initrd} = make ]]
476      mkinitrd  then
477  elif [ "$initrd" == "remove" ]; then   mkinitrd
478      rminitrd  elif [[ ${initrd} = remove ]]
479    then
480     rminitrd
481  fi  fi
482    
483  if [ ! -x $grubby ] ; then  if [ ! -x ${grubby} ]
484      [ -n "$verbose" ] && echo "$grubby does not exist"  then
485      exit 0   [[ -n ${verbose} ]] && echo "${grubby} does not exist"
486     exit 0
487  fi  fi
488    
489    [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
490  [ -n "$grubConfig" ] && [ -f "$grubConfig" ] && cfgGrub=1;  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
 [ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1;  
491    
492  # if we have a lilo config on an x86 box, see if the default boot loader  # if we have a lilo config on an x86 box, see if the default boot loader
493  # is lilo to determine if it should be run  # is lilo to determine if it should be run
494  if [ -n "$cfgLilo" -a -n "$isx86" ]; then  if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]
495      runLilo=$($grubby --bootloader-probe | grep lilo)  then
496     runLilo=$(${grubby} --bootloader-probe | grep lilo)
497  fi  fi
498    
499  if [ "$mode" == "--install" ]; then  if [[ ${mode} = --install ]]
500      install  then
501  elif [ "$mode" == "--remove" ]; then   install
502      remove  elif [[ ${mode} = --remove ]]
503    then
504     remove
505    elif [[ ${mode} = --update ]]
506    then
507     update
508  fi  fi
509    
510  exit 0  exit 0

Legend:
Removed from v.532  
changed lines
  Added in v.924