Magellan Linux

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

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

trunk/mkinitrd-magellan/grubby/new-kernel-pkg revision 532 by niro, Sat Sep 1 22:45:15 2007 UTC trunk/grubby/new-kernel-pkg revision 1332 by niro, Fri Jun 3 20:32:19 2011 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/conf.d/grubby ] && . /etc/conf.d/grubby
43    
44  cfgGrub=""  cfgGrub=""
45  cfgLilo=""  cfgLilo=""
# 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    run_grub2()
113    {
114     if [ -d /boot/grub2 -a -x /sbin/grub2-mkconfig ]
115     then
116     cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.old
117     /sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
118     fi
119  }  }
120    
121  install() {  install()
122      # XXX kernel should be able to be specified also (or work right on ia64)  {
123      if [ ! -f $bootPrefix/$kernelName-$version ] ; then   # XXX kernel should be able to be specified also (or work right on ia64)
124   [ -n "$verbose" ] && echo "kernel for $version does not exist, not running grubby"   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]
125   return   then
126      fi   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
127         return
128      INITRD=""   fi
129      if [ -f $initrdfile ]; then  
130   [ -n "$verbose" ] && echo "found $initrdfile and using it with grubby"   INITRD=""
131   INITRD="--initrd $initrdfile"   if [ -f ${initrdfile} ]
132      fi   then
133     [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
134      # FIXME: is this a good heuristic to find out if we're on iSeries?   INITRD="--initrd ${initrdfile}"
135      if [ -d /proc/iSeries ]; then   fi
136   [ -n "$verbose" ] && echo "On an iSeries, just making img file"  
137   if [ -z $initrdfile  ]; then   # FIXME: is this a good heuristic to find out if we're on iSeries?
138      [ -n "$verbose" ] && echo "No initrd, just adding system map"   if [ -d /proc/iSeries ]
139      /sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinitrd-$version   then
140     [[ -n ${verbose} ]] && echo "On an iSeries, just making img file"
141     if [[ -z ${initrdfile} ]]
142     then
143     [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
144     /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version}
145     else
146     /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version}
147     /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null
148     rm ${bootPrefix}/vmlinux.sm-${version}
149     fi
150     return
151     fi
152    
153     # Run grub2's configuration update in parallel, if it is installed
154     run_grub2
155    
156     # get the root filesystem to use
157     rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)
158    
159     if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
160     then
161     [[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf"
162     cfgLilo=""
163     fi
164    
165     if [[ -n ${cfgGrub} ]]
166     then
167     [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
168    
169     if [[ -n ${banner} ]]
170     then
171     title="${banner} (${version})"
172     elif [ -f /etc/mageversion ]
173     then
174     title="Magellan Linux $(< /etc/mageversion) (${version})"
175     else
176     title="Magellan Linux (${version})"
177     fi
178     ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \
179     ${INITRD} --copy-default ${makedefault} --title "${title}" \
180     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
181     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
182   else   else
183      /sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinux.sm-$version   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
184      /sbin/addRamDisk $initrdfile $bootPrefix/System.map-$version $bootPrefix/vmlinux.sm-$version $bootPrefix/vmlinitrd-$version 2>/dev/null   fi
185      rm $bootPrefix/vmlinux.sm-$version  
186   fi   if [[ -n ${cfgLilo} ]]
187   return   then
188      fi   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
189    
190      # get the root filesystem to use; if it's on a label make sure it's   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \
191      # been configured. if not, get the root device from mount   --copy-default ${makedefault} --title ${version} \
192      rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
193      short=$(echo $rootdevice | cut -d= -f1)   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \
194      if [ "$short" == "LABEL" ]; then   --${liloFlag}
195   label=$(echo $rootdevice | cut -d= -f2 |head -n 1)  
196   device=$(echo "showlabels" | /sbin/nash  --force --quiet |   if [[ -n ${runLilo} ]]
197   awk '$2 == "'$label'" {print $1}')   then
198   if [ -z "$device" ]; then   [[ -n ${verbose} ]] && echo "running ${lilo}"
199      rootdevice=$(mount | awk '$3 == "/" { print $1 }')   if [ ! -x ${lilo} ]
200   fi   then
201      fi   [[ -n ${verbose} ]] && echo "${lilo} does not exist"
202     else
203      if [ -n "$mbkernel" ]; then   ${lilo} > /dev/null
204   mb="--add-multiboot=$mbkernel"   fi
205   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)"  
206   else   else
207      title="Magellan Linux ($version)"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
208     fi
209    }
210    
211    remove()
212    {
213     # FIXME: is this a good heuristic to find out if we're on iSeries?
214     if [ -d /proc/iSeries ]
215     then
216     [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
217     rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null
218     return
219   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  
220    
221     # Run grub2's configuration update in parallel, if it is installed
222     run_grub2
223    
224     if [[ -n ${cfgGrub} ]]
225     then
226     [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
227     ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version}
228     else
229     [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
230     fi
231    
232     if [[ -n ${cfgLilo} ]]
233     then
234     [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
235     ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}
236    
237     if [[ -n ${runLilo} ]]
238     then
239     [[ -n ${verbose} ]] && echo "running ${lilo}"
240     if [ ! -x ${lilo} ]
241     then
242     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
243     else
244     ${lilo} > /dev/null
245     fi
246     fi
247     else
248     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
249     fi
250  }  }
251    
252  remove() {  update()
253      # FIXME: is this a good heuristic to find out if we're on iSeries?  {
254      if [ -d /proc/iSeries ]; then   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]
255   [ -n "$verbose" ] && echo "On an iSeries, remove img file"   then
256   rm -f $bootPrefix/$kernelName-$version.img 2>/dev/null   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
257   return   return
258      fi   fi
259    
260      if [ -n "$cfgGrub" ]; then   INITRD=""
261   [ -n "$verbose" ] && echo "removing $version from $grubConfig"   if [ -f ${initrdfile} ]
262   /sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version   then
263      else   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
264   [ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"   INITRD="--initrd ${initrdfile}"
265      fi   fi
266    
267      if [ -n "$cfgLilo" ]; then   # Run grub2's configuration update in parallel, if it is installed
268   [ -n "$verbose" ] && echo "removing $version from $liloConfig"   run_grub2
269   /sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version    \  
270       --$liloFlag   if [[ -n ${cfgGrub} ]]
271     then
272   if [ -n "$runLilo" ]; then   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
273      [ -n "$verbose" ] && echo "running $lilo"   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \
274      if [ ! -x $lilo ] ; then   ${INITRD} \
275   [ -n "$verbose" ] && echo "$lilo does not exist"   ${kernargs:+--args="${kernargs}"} \
276      else   ${removeargs:+--remove-args="${removeargs}"}
277   $lilo > /dev/null   else
278      fi   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
279   fi   fi
280      else  
281   [ -n "$verbose" ] && echo "$liloConfig does not exist, not running grubby"   if [[ -n ${cfgLilo} ]]
282      fi   then
283     [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
284     ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \
285     ${INITRD} \
286     ${kernargs:+--args="${kernargs}"} \
287     ${removeargs:+--remove-args="${removeargs}"} \
288     --${liloFlag}
289    
290     if [[ -n ${runLilo} ]]
291     then
292     [[ -n ${verbose} ]] && echo "running ${lilo}"
293     if [ ! -x ${lilo} ]
294     then
295     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
296     else
297     ${lilo} > /dev/null
298     fi
299     fi
300     else
301     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
302     fi
303  }  }
304    
305  mkinitrd() {  mkinitrd()
306      [ -n "$verbose" ] && echo "creating initrd $initrdfile using $version"  {
307      /sbin/mkinitrd --allow-missing -f $initrdfile $version   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
308      rc=$?   /sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}
309      if [ $rc != 0 ]; then   rc=$?
310   echo "mkinitrd failed" >&2   if [ ${rc} != 0 ]
311   exit 1   then
312      fi   echo "mkinitrd failed" >&2
313     exit 1
314     fi
315  }  }
316    
317  rminitrd() {  rminitrd()
318      [ -n "$verbose" ] && echo "removing initrd $initrdfile"  {
319      [ -f $initrdfile ] && rm -f $initrdfile   [[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}"
320     [ -f ${initrdfile} ] && rm -f ${initrdfile}
321  }  }
322    
323  doDepmod() {  doDepmod()
324      [ -n "$verbose" ] && echo "running depmod for $version"  {
325      depmod -ae -F /boot/System.map-$version $version   [[ -n ${verbose} ]] && echo "running depmod for ${version}"
326     depmod -ae -F /boot/System.map-${version} ${version}
327  }  }
328    
329  doRmmoddep() {  doRmmoddep()
330      [ -n "$verbose" ] && echo "removing modules.dep info for $version"  {
331      [ -d /lib/modules/$version ] && rm -f /lib/modules/$version/modules.*       [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
332     [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*
333  }  }
334    
335    
336  while [ $# -gt 0 ]; do  while [ $# -gt 0 ]
337      case $1 in  do
338   --mkinitrd)   case $1 in
339      initrd="make"   --mkinitrd)
340      ;;   initrd="make"
341     ;;
342   --rminitrd)  
343      initrd="remove"   --rminitrd)
344      ;;   initrd="remove"
345     ;;
346   --initrdfile*)  
347      if echo $1 | grep '=' >/dev/null ; then   --initrdfile*)
348       initrdfile=`echo $1 | sed 's/^--initrdfile=//'`   if echo $1 | grep '=' >/dev/null
349      else   then
350   initrdfile=$2   initrdfile=$(echo $1 | sed 's/^--initrdfile=//')
351   shift   else
352      fi       initrdfile=$2
353      ;;   shift
354     fi
355   --kernel-args*)   ;;
356      if echo $1 | grep '=' >/dev/null ; then  
357       kernargs=`echo $1 | sed 's/^--kernel-args=//'`   --kernel-args*)
358      else   if echo $1 | grep '=' >/dev/null
359   kernargs=$2   then
360   shift   kernargs=$(echo $1 | sed 's/^--kernel-args=//')
361      fi       else
362      ;;   kernargs=$2
363     shift
364   --banner*)   fi
365      if echo $1 | grep '=' >/dev/null ; then   ;;
366       banner=`echo $1 | sed 's/^--banner=//'`  
367      else   --remove-args*)
368   banner=$2   if echo $1 | grep '=' >/dev/null
369   shift   then
370      fi       removeargs=$(echo $1 | sed 's/^--remove-args=//')
371      ;;   else
372     removeargs=$2
373   --multiboot*)   shift
374      if echo $1 |grep '=' >/dev/null; then   fi
375   mbkernel=`echo $1 | sed 's/^--multiboot=//'`   ;;
376      else  
377   # can't really support having an optional second arg here   --banner*)
378   # sorry!   if echo $1 | grep '=' >/dev/null
379   mbkernel="/boot/xen.gz"   then
380      fi   banner=$(echo $1 | sed 's/^--banner=//')
381      ;;   else
382     banner=$2
383   --mbargs*)   shift
384      if echo $1 |grep '=' >/dev/null; then   fi
385   mbargs=`echo $1 | sed 's/^--mbargs=//'`   ;;
386      else  
387   mbargs=$2   --multiboot*)
388   shift   if echo $1 |grep '=' >/dev/null
389      fi   then
390      ;;   mbkernel=$(echo $1 | sed 's/^--multiboot=//')
391     else
392   --depmod)   # can't really support having an optional second arg here
393      moddep="make"   # sorry!
394      ;;   mbkernel="/boot/xen.gz"
395     fi
396   --rmmoddep)   ;;
397      moddep="remove"  
398      ;;   --mbargs*)
399     if echo $1 |grep '=' >/dev/null
400   --make-default)   then
401      makedefault="--make-default"   mbargs=$(echo $1 | sed 's/^--mbargs=//')
402      ;;   else
403     mbargs="$2"
404   --package)   shift
405      if echo $1 | grep '=' >/dev/null ; then   fi
406       package=`echo $1 | sed 's/^--package=//'`   ;;
407      else  
408   package=$2   --depmod)
409   shift   moddep="make"
410      fi       ;;
411      ;;  
412     --rmmoddep)
413   -v)   moddep="remove"
414      verbose=-v   ;;
415      ;;  
416     --make-default)
417   *)   makedefault="--make-default"
418      if [ -z "$mode" ]; then   ;;
419   mode=$1  
420      elif [ -z "$version" ]; then   --package)
421   version=$1   if echo $1 | grep '=' >/dev/null
422      else   then
423   usage   package=$(echo $1 | sed 's/^--package=//')
424      fi   else
425      ;;   package=$2
426      esac   shift
427     fi
428     ;;
429    
430     -v)
431     verbose=-v
432     ;;
433    
434     *)
435     if [[ -z ${mode} ]]
436     then
437     mode=$1
438     elif [[ -z ${version} ]]
439     then
440     version=$1
441     else
442     usage
443     fi
444     ;;
445     esac
446    
447      shift   shift
448  done  done
449    
450  # make sure the mode is valid  # make sure the mode is valid
451  if [ "$mode" != "--install" -a "$mode" != "--remove" ] ; then  if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]]
452      usage  then
453     usage
454  fi  fi
455    
456  if [ -z "$version" ]; then  if [[ -z ${version} ]]
457      usage  then
458     usage
459  fi  fi
460    
461  if [ "$mode" != "--install" -a "$makedefault" ]; then  if [ "${mode}" != "--install" -a "${makedefault}" ]
462      usage  then
463     usage
464  fi  fi
465    
466  # 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`  
467    
468  # kernel image for 2.4 is vmlinux  # kernel image for 2.4 is kernel
469  if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then  if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
470    if [ "$kernelmajor" == "2.4" ]; then  then
471        kernelName=vmlinux   if [[ ${kernelmajor} = 2.4 ]]
472    fi   then
473     kernelName=kernel
474     fi
475  fi  fi
476    
   
477  # 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
478  if [ -z "$initrdfile" ]; then  if [[ -z ${initrdfile} ]]
479      if [ `uname -m` = "ia64" ]; then  then
480   initrdfile="/boot/efi/EFI/redhat/initrd-$version.img"   INITRD_NAME_PREFIX="initrd"
481      else  
482   initrdfile="/boot/initrd-$version.img"   if [[ $(uname -m) = ia64 ]]
483      fi   then
484     initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img"
485     else
486     initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img"
487     fi
488  fi  fi
489  [ -n "$verbose" ] && echo "initrdfile is $initrdfile"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
490    
491  # 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
492  if [ "$mode" == "--install" -a "$UPDATEDEFAULT" == "yes" -a -n "$package" -a -n "$DEFAULTKERNEL" -a "$package" == "$DEFAULTKERNEL" ]; then  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&
493      makedefault="--make-default"   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]
494      [ -n "$verbose" ] && echo "making it the default based on config"  then
495     makedefault="--make-default"
496     [[ -n ${verbose} ]] && echo "making it the default based on config"
497  fi  fi
498    
499  if [ "$moddep" == "make" ]; then  if [[ ${moddep} = make ]]
500      doDepmod  then
501  elif [ "$moddep" == "remove" ]; then   doDepmod
502      doRmmoddep  elif [[ ${moddep} = remove ]]
503    then
504     doRmmoddep
505  fi  fi
506    
507  if [ "$initrd" == "make" ]; then  if [[ ${initrd} = make ]]
508      mkinitrd  then
509  elif [ "$initrd" == "remove" ]; then   mkinitrd
510      rminitrd  elif [[ ${initrd} = remove ]]
511    then
512     rminitrd
513  fi  fi
514    
515  if [ ! -x $grubby ] ; then  if [ ! -x ${grubby} ]
516      [ -n "$verbose" ] && echo "$grubby does not exist"  then
517      exit 0   [[ -n ${verbose} ]] && echo "${grubby} does not exist"
518     exit 0
519  fi  fi
520    
521    [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
522  [ -n "$grubConfig" ] && [ -f "$grubConfig" ] && cfgGrub=1;  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
 [ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1;  
523    
524  # 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
525  # is lilo to determine if it should be run  # is lilo to determine if it should be run
526  if [ -n "$cfgLilo" -a -n "$isx86" ]; then  if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]
527      runLilo=$($grubby --bootloader-probe | grep lilo)  then
528     runLilo=$(${grubby} --bootloader-probe | grep lilo)
529  fi  fi
530    
531  if [ "$mode" == "--install" ]; then  if [[ ${mode} = --install ]]
532      install  then
533  elif [ "$mode" == "--remove" ]; then   install
534      remove  elif [[ ${mode} = --remove ]]
535    then
536     remove
537    elif [[ ${mode} = --update ]]
538    then
539     update
540  fi  fi
541    
542  exit 0  exit 0

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