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 2993 by niro, Thu Jun 30 10:35:55 2016 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    read_os_release()
29    {
30     local NAME
31     local ID
32     local Version
33     local Version_ID
34     local PRETTY_NAME
35     local ANSI_COLOR
36     local CPE_NAME
37    
38     if [[ -f /etc/os-release ]]
39     then
40     source /etc/os-release
41    
42     case $1 in
43     name) echo "${NAME}" ;;
44     id) echo "${ID}" ;;
45     version) echo "${Version}" ;;
46     version_id) echo "${Version_ID}" ;;
47     pretty_name) echo "${PRETTY_NAME}" ;;
48     ansi_color) echo "${ANSI_COLOR}" ;;
49     cpe_name) echo "${CPE_NAME}" ;;
50     esac
51     fi
52    }
53    
54  PATH=/sbin:/bin:$PATH  PATH=/sbin:/bin:$PATH
55    
# Line 18  lilo=/sbin/lilo Line 58  lilo=/sbin/lilo
58  # some defaults that are sane for most arches  # some defaults that are sane for most arches
59  kernelName=kernel  kernelName=kernel
60    
61  if [ -x ./grubby ]; then  if [ -x ./grubby ]
62      grubby=./grubby  then
63     grubby=./grubby
64  else  else
65      grubby=/sbin/grubby   grubby=/sbin/grubby
66  fi  fi
67    
68  [ -f /etc/sysconfig/kernel ] && . /etc/sysconfig/kernel  [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby
69    [ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot
70    
71    cfgGrub2=""
72    cfgGrub2Efi=""
73  cfgGrub=""  cfgGrub=""
74  cfgLilo=""  cfgLilo=""
75    cfgExtlinux=""
76    cfguBoot=""
77  runLilo=""  runLilo=""
78  grubConfig=""  grubConfig=""
79    grub2Config=""
80    grub2EfiConfig=""
81    extlinuxConfig=""
82    ubootScript="/boot/boot.scr"
83    
84  ARCH=$(uname -m)  ARCH=$(uname -m)
85    
86  if [ $ARCH = 'ia64' ]; then  if [[ ${ARCH} = ia64 ]]
87      liloConfig=/boot/efi/EFI/redhat/elilo.conf  then
88      bootPrefix=/boot/efi/EFI/redhat   liloConfig=/boot/efi/EFI/redhat/elilo.conf
89      liloFlag=elilo   bootPrefix=/boot/efi/EFI/redhat
90      isx86=""   liloFlag=elilo
91  elif [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then   isx86=""
92      liloConfig=/etc/yaboot.conf  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
93      bootPrefix=/boot  then
94      lilo=/sbin/ybin   liloConfig=/etc/yaboot.conf
95      liloFlag=yaboot   grub2Config=/boot/grub/grub.cfg
96      runLilo="yes"   bootPrefix=/boot
97      isx86=""   lilo=/sbin/ybin
98  elif [ $ARCH = 'sparc' -o $ARCH = 'sparc64' ]; then   liloFlag=yaboot
99      liloConfig=/etc/silo.conf   runLilo="yes"
100      bootPrefix=/boot   isx86=""
101      liloFlag=silo  elif [[ ${ARCH} = sparc ]] || [[ ${ARCH} = sparc64 ]]
102      lilo=/sbin/silo  then
103      isx86=""   liloConfig=/etc/silo.conf
104  elif [ $ARCH = 's390' -o $ARCH = 's390x' ]; then   bootPrefix=/boot
105      liloConfig=/etc/zipl.conf   liloFlag=silo
106      bootPrefix=/boot   lilo=/sbin/silo
107      liloFlag=zipl   isx86=""
108      lilo=/sbin/zipl  elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
109      runLilo="yes"  then
110      isx86=""   liloConfig=/etc/zipl.conf
111     bootPrefix=/boot
112     liloFlag=zipl
113     lilo=/sbin/zipl
114     runLilo="yes"
115     isx86=""
116    elif [[ ${ARCH} =~ armv[5|7].*l ]]
117    then
118     liloConfig=""
119     bootPrefix=/boot
120     extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null)
121     ubootDir=${UBOOT_DIR:-"/boot"}
122     ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
123     ubootKList=${UBOOT_KLIST:-"klist.txt"}
124     ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
125     ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
126     ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
127     ubootAddress=${UBOOT_IMGADDR:-"0x00008000"}
128     mounted=""
129     liloFlag=""
130     isx86=""
131  else  else
132      # this leaves i?86 and x86_64   # this leaves i?86 and x86_64
133      liloConfig=/etc/lilo.conf   liloConfig=/etc/lilo.conf
134      grubConfig=/boot/grub/grub.conf   grubConfig=/boot/grub/grub.conf
135      bootPrefix=/boot   grub2Config=/boot/grub/grub.cfg
136      liloFlag=lilo   grub2EfiConfig=/boot/grub/grub-efi.cfg
137      isx86="yes"   extlinuxConfig=/boot/extlinux/extlinux.conf
138     bootPrefix=/boot
139     liloFlag=lilo
140     isx86="yes"
141  fi  fi
142    
143  mode=""  mode=""
144  version=""  version=""
145  initrd=""  initrd=""
146    dracut=""
147    dracuthostonly=""
148  initrdfile=""  initrdfile=""
149    devtreefile=""
150  moddep=""  moddep=""
151  verbose=""  verbose=""
152  makedefault=""  makedefault=""
153  package=""  package=""
154  mbkernel=""  mbkernel="${HYPERVISOR}"
155  mbargs=""  mbargs="${HYPERVISOR_ARGS}"
156    adddracutargs=""
157  usage() {  addplymouthinitrd=""
158      echo "Usage: `basename $0` [-v] [--mkinitrd] [--rminitrd]" >&2  DEBUGARG="systemd.log_level=debug systemd.log_target=kmsg"
159      echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2  
160      echo "       [--kernel-args=<args>] [--banner=<banner>]" >&2  usage()
161      echo "       [--multiboot=multiboot] [--mbargs=mbargs]" >&2  {
162      echo "       [--make-default] <--install | --remove> <kernel-version>" >&2   echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
163      echo "       (ex: `basename $0` --mkinitrd --depmod --install 2.4.7-2)" >&2   echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
164      exit 1   echo "       [--kernel-args=<args>] [--remove-args=<args>]" >&2
165  }   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2
166     echo "       [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
167  install() {   echo "       [--add-plymouth-initrd]" >&2
168      # XXX kernel should be able to be specified also (or work right on ia64)   echo "       [--host-only] [--devtree=<devicetree.dtb>] [--devtreedir=</devicetree/path/>]" >&2
169      if [ ! -f $bootPrefix/$kernelName-$version ] ; then   echo "       <--install | --remove | --update> <kernel-version>" >&2
170   [ -n "$verbose" ] && echo "kernel for $version does not exist, not running grubby"   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
  return  
     fi  
       
     INITRD=""  
     if [ -f $initrdfile ]; then  
  [ -n "$verbose" ] && echo "found $initrdfile and using it with grubby"  
  INITRD="--initrd $initrdfile"  
     fi  
   
     # FIXME: is this a good heuristic to find out if we're on iSeries?  
     if [ -d /proc/iSeries ]; then  
  [ -n "$verbose" ] && echo "On an iSeries, just making img file"  
  if [ -z $initrdfile  ]; then  
     [ -n "$verbose" ] && echo "No initrd, just adding system map"  
     /sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinitrd-$version  
  else  
     /sbin/addSystemMap $bootPrefix/System.map-$version $bootPrefix/$kernelName-$version $bootPrefix/vmlinux.sm-$version  
     /sbin/addRamDisk $initrdfile $bootPrefix/System.map-$version $bootPrefix/vmlinux.sm-$version $bootPrefix/vmlinitrd-$version 2>/dev/null  
     rm $bootPrefix/vmlinux.sm-$version  
  fi  
  return  
     fi  
   
     # get the root filesystem to use; if it's on a label make sure it's  
     # been configured. if not, get the root device from mount  
     rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)  
     short=$(echo $rootdevice | cut -d= -f1)  
     if [ "$short" == "LABEL" ]; then  
  label=$(echo $rootdevice | cut -d= -f2 |head -n 1)  
  device=$(echo "showlabels" | /sbin/nash  --force --quiet |  
  awk '$2 == "'$label'" {print $1}')  
  if [ -z "$device" ]; then  
     rootdevice=$(mount | awk '$3 == "/" { print $1 }')  
  fi  
     fi  
   
     if [ -n "$mbkernel" ]; then  
  mb="--add-multiboot=$mbkernel"  
  if [ -n "$mbargs" ]; then  
     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)"  
  else  
     title="Magellan Linux ($version)"  
  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  
   
 }  
   
 remove() {  
     # FIXME: is this a good heuristic to find out if we're on iSeries?  
     if [ -d /proc/iSeries ]; then  
  [ -n "$verbose" ] && echo "On an iSeries, remove img file"  
  rm -f $bootPrefix/$kernelName-$version.img 2>/dev/null  
  return  
     fi  
   
     if [ -n "$cfgGrub" ]; then  
  [ -n "$verbose" ] && echo "removing $version from $grubConfig"  
  /sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$version  
     else  
  [ -n "$verbose" ] && echo "$grubConfig does not exist, not running grubby"  
     fi  
   
     if [ -n "$cfgLilo" ]; then  
  [ -n "$verbose" ] && echo "removing $version from $liloConfig"  
  /sbin/grubby --remove-kernel=$bootPrefix/$kernelName-$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  
 }  
   
 mkinitrd() {  
     [ -n "$verbose" ] && echo "creating initrd $initrdfile using $version"  
     /sbin/mkinitrd --allow-missing -f $initrdfile $version  
     rc=$?  
     if [ $rc != 0 ]; then  
  echo "mkinitrd failed" >&2  
171   exit 1   exit 1
     fi  
172  }  }
173    
174  rminitrd() {  rungrubby()
175      [ -n "$verbose" ] && echo "removing initrd $initrdfile"  {
176      [ -f $initrdfile ] && rm -f $initrdfile   if [[ $1 == --debug ]]
177     then
178     [[ ${MAKEDEBUG} != yes ]] && return 0
179     [[ -n ${verbose} ]] && echo "- First, making a debug entry."
180     if [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
181     then
182     declare -x debugtitle="_with_debugging"
183     else
184     declare -x debugtitle=" with debugging"
185     fi
186     declare -x debugargs="${DEBUGARG}"
187     shift
188     else
189     [[ -n ${verbose} ] && echo "- Making a normal entry."
190     fi
191     $(eval $grubby $@)
192     export -n debugargs
193     export -n debugtitle
194     unset debugargs
195     unset debugtitle
196  }  }
197    
198  doDepmod() {  set_title()
199      [ -n "$verbose" ] && echo "running depmod for $version"  {
200      depmod -ae -F /boot/System.map-$version $version   if [[ -n ${banner} ]]
201     then
202     if [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
203     then
204     title=$(echo ${banner} | sed 's/ /_/g')
205     else
206     title="${banner} [ ${version} ]"
207     fi
208     elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
209     then
210     title=$(echo ${version} | sed 's/ /_/g')
211     elif [ -f /etc/os-release ]
212     then
213     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
214     elif [ -f /etc/mageversion ]
215     then
216     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
217     else
218     title="Magellan Linux [ ${version} ]"
219     fi
220  }  }
221    
222  doRmmoddep() {  install()
223      [ -n "$verbose" ] && echo "removing modules.dep info for $version"  {
224      [ -d /lib/modules/$version ] && rm -f /lib/modules/$version/modules.*       # XXX kernel should be able to be specified also (or work right on ia64)
225     if [ ! -f ${kernelImage} ]
226     then
227     [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
228     return
229     fi
230    
231     INITRD=""
232     if [ -f ${initrdfile} ]
233     then
234     [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
235     INITRD="--initrd ${initrdfile}"
236    
237     if [[ -n ${addplymouthinitrd} ]]
238     then
239     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
240     fi
241     fi
242    
243     DEVTREE=""
244     if [[ -n ${devtreefile} ]] && [ -f ${devtreefile} ]
245     then
246     [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby"
247     DEVTREE="--devtree ${devtreefile}"
248     fi
249    
250     DEVTREEDIR=""
251     if [[ -n ${devtreedir} ]] && [ -d ${devtreedir} ]
252     then
253     [ -n ${verbose} ] && echo "found ${devtreedir} and using it with grubby"
254     DEVTREEDIR="--devtreedir ${devtreedir}"
255     fi
256    
257     # FIXME: is this a good heuristic to find out if we're on iSeries?
258     if [ -d /proc/iSeries ]
259     then
260     [[ -n ${verbose} ]] && echo "On an iSeries, just making img file"
261     if [[ -z ${initrdfile} ]]
262     then
263     [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
264     /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version}
265     else
266     /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version}
267     /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null
268     rm ${bootPrefix}/vmlinux.sm-${version}
269     fi
270     return
271     fi
272    
273     # get the root filesystem to use
274     rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab  2>/dev/null)
275     if [[ -z $rootdevice ]]
276     then
277     rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline)
278     fi
279    
280     if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
281     then
282     [[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf"
283     cfgLilo=""
284     fi
285    
286     set_title
287    
288     if [[ -n ${cfgGrub} ]]
289     then
290     [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
291    
292     ARGS="--grub -c ${grubConfig} --add-kernel=${kernelImage} ${INITRD} \
293     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
294     ${mbargs:+--mbargs=\"${mbargs}\"} \
295     --title=\"${title}\${debugtitle}\" --copy-default \
296     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
297     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
298     rungrubby --debug ${ARGS}
299     rungrubby ${ARGS} ${makedefault}
300     else
301     [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
302     fi
303     if [[ -n ${cfgGrub2} ]]
304     then
305     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
306    
307     ARGS="--grub2 -c ${grub2Config} --add-kernel=${kernelImage} ${INITRD} \
308     --copy-default --title \"${title}\${debugtitle}\" \
309     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
310     ${mbargs:+--mbargs=\"${mbargs}\"} \
311     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
312     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
313     rungrubby --debug ${ARGS}
314     rungrubby ${ARGS} ${makedefault}
315     else
316     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
317     fi
318     if [[ -n ${cfgGrub2Efi} ]]
319     then
320     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
321    
322     ARGS="--grub2 -c ${grub2EfiConfig} --efi \
323     --add-kernel=${kernelImage} ${DEVTREE} ${INITRD} \
324     --copy-default --title \"${title}\${debugtitle}\" \
325     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
326     ${mbargs:+--mbargs=\"${mbargs}\"} \
327     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
328     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
329     rungrubby --debug ${ARGS}
330     rungrubby ${ARGS} ${makedefault}
331     else
332     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"
333     fi
334    
335     if [[ -n ${cfgLilo} ]]
336     then
337     [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
338    
339     ARGS="--${liloFlag} --add-kernel=${kernelImage} ${INITRD} \
340     --copy-default --title \"${title}\${debugtitle}\" \
341     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
342     ${mbargs:+--mbargs=\"${mbargs}\"} \
343     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
344     --remove-kernel=\"TITLE=${version}\""
345     rungrubby --debug ${ARGS}
346     rungrubby ${ARGS} ${makedefault}
347    
348     if [[ -n ${runLilo} ]]
349     then
350     [[ -n ${verbose} ]] && echo "running ${lilo}"
351     if [ ! -x ${lilo} ]
352     then
353     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
354     else
355     ${lilo} > /dev/null
356     fi
357     fi
358     else
359     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
360     fi
361    
362     if [[ -n ${cfgExtlinux} ]]
363     then
364     [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
365    
366     ARGS="--extlinux -c ${extlinuxConfig} --add-kernel=${kernelImage} \
367     ${DEVTREEDIR} ${DEVTREE} \
368     ${INITRD} --copy-default --title \"${title}\${debugtitle}\" \
369     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
370     ${mbargs:+--mbargs=\"${mbargs}\"} \
371     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
372     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
373     rungrubby --debug ${ARGS}
374     rungrubby ${ARGS} ${makedefault}
375     else
376     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
377     fi
378  }  }
379    
380    remove()
381    {
382     # FIXME: is this a good heuristic to find out if we're on iSeries?
383     if [ -d /proc/iSeries ]
384     then
385     [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
386     rm -f ${kernelImage}.img 2>/dev/null
387     return
388     fi
389    
390  while [ $# -gt 0 ]; do   if [[ -n ${cfgGrub} ]]
391      case $1 in   then
392   --mkinitrd)   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
393      initrd="make"   ${grubby} --grub -c ${grubConfig} \
394      ;;   --remove-kernel=${kernelImage}
395     else
396     [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
397     fi
398     if [[ -n ${cfgGrub2} ]]
399     then
400     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
401     ${grubby} --grub2 -c ${grub2Config} \
402     --remove-kernel=${kernelImage}
403     else
404     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
405     fi
406     if [[ -n ${cfgGrub2Efi} ]]
407     then
408     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
409     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
410     --remove-kernel=${kernelImage}
411     else
412     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
413     fi
414    
415   --rminitrd)   if [[ -n ${cfgLilo} ]]
416      initrd="remove"   then
417      ;;   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
418     ${grubby} --remove-kernel=${kernelImage} --${liloFlag}
419    
420     if [[ -n ${runLilo} ]]
421     then
422     [[ -n ${verbose} ]] && echo "running ${lilo}"
423     if [ ! -x ${lilo} ]
424     then
425     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
426     else
427     ${lilo} > /dev/null
428     fi
429     fi
430     else
431     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
432     fi
433    
434   --initrdfile*)   if [[ -n ${cfguBoot} ]]
435      if echo $1 | grep '=' >/dev/null ; then   then
436       initrdfile=`echo $1 | sed 's/^--initrdfile=//'`   [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..."
437      else  
438   initrdfile=$2   if [ -f ${ubootDir}/${ubootKList} ]
439   shift   then
440      fi       tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
441      ;;   curversion=$(tail -n1 ${ubootDir}/${ubootKList})
442     sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList}
443     newversion=$(tail -n1 ${tmpKList})
444     if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
445     then
446     if [[ ${curversion} != ${newversion} ]]
447     then
448     cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage}
449     if [ $? -ne 0 ]
450     then
451     [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit
452     fi
453     cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd}
454     if [ $? -ne 0 ]
455     then
456     [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit
457     fi
458     fi
459    
460     [[ -n ${verbose} ]] && echo "removing uImage-${version}"
461     if [ -f ${ubootDir}/uImage-${version} ]
462     then
463     rm -f ${ubootDir}/uImage-${version}
464     else
465     [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!"
466     fi
467    
468     [[ -n ${verbose} ]] && echo "removing uInitrd-${version}"
469     if [ -f ${ubootDir}/uInitrd-${version} ]
470     then
471     rm -f ${ubootDir}/uInitrd-${version}
472     else
473     [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!"
474     fi
475    
476     mv ${tmpKList} ${ubootDir}/${ubootKList}
477     [ -x /sbin/a-b-c ] && /sbin/a-b-c
478     else
479     [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
480     [ -f ${tmpKList} ] && rm -f ${tmpKList}
481     fi
482     else
483     [[ -n ${verbose} ]] && echo "No previous kernel version.  U-Boot images not removed!"
484     fi
485     else
486     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
487     fi
488    
489   --kernel-args*)   if [[ -n ${cfgExtlinux} ]]
490      if echo $1 | grep '=' >/dev/null ; then   then
491       kernargs=`echo $1 | sed 's/^--kernel-args=//'`   [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}"
492      else   ${grubby} --extlinux -c ${extlinuxConfig} \
493   kernargs=$2   --remove-kernel=${kernelImage}
494   shift   else
495      fi       [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
496      ;;   fi
497    }
498    
499   --banner*)  update()
500      if echo $1 | grep '=' >/dev/null ; then  {
501       banner=`echo $1 | sed 's/^--banner=//'`   if [ ! -f ${kernelImage} ]
502      else   then
503   banner=$2   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
504   shift   return
505      fi       fi
     ;;  
506    
507   --multiboot*)   set_title
     if echo $1 |grep '=' >/dev/null; then  
  mbkernel=`echo $1 | sed 's/^--multiboot=//'`  
     else  
  # can't really support having an optional second arg here  
  # sorry!  
  mbkernel="/boot/xen.gz"  
     fi  
     ;;  
   
  --mbargs*)  
     if echo $1 |grep '=' >/dev/null; then  
  mbargs=`echo $1 | sed 's/^--mbargs=//'`  
     else  
  mbargs=$2  
  shift  
     fi  
     ;;  
508    
509   --depmod)   INITRD=""
510      moddep="make"   if [ -f ${initrdfile} ]
511      ;;   then
512     [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
513   --rmmoddep)   INITRD="--initrd ${initrdfile}"
514      moddep="remove"  
515      ;;   if [[ -n ${addplymouthinitrd} ]]
516     then
517   --make-default)   INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
518      makedefault="--make-default"   fi
519      ;;   fi
520    
521   --package)   DEVTREE=""
522      if echo $1 | grep '=' >/dev/null ; then   if [[ -n ${devtreefile} ]] && [ -f ${devtreefile} ]
523       package=`echo $1 | sed 's/^--package=//'`   then
524      else   [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby"
525   package=$2   DEVTREE="--devtree ${devtreefile}"
526   shift   fi
     fi      
     ;;  
527    
528   -v)   DEVTREEDIR=""
529      verbose=-v   if [[ -n ${devtreedir} ]] && [ -d ${devtreedir} ]
530      ;;   then
531     [[ -n ${verbose} ]] && echo "found ${devtreedir} and using it with grubby"
532   *)   DEVTREEDIR="--devtreedir ${devtreedir}"
533      if [ -z "$mode" ]; then   fi
534   mode=$1  
535      elif [ -z "$version" ]; then   if [[ -n ${cfgGrub} ]]
536   version=$1   then
537      else   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
538   usage   ARGS="--grub -c ${grubConfig} --update-kernel=${kernelImage} ${INITRD} \
539      fi   ${kernargs:+--args=\"${kernargs}\"} \
540      ;;   ${removeargs:+--remove-args=\"${removeargs}\"} \
541      esac   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
542     --title=\"${title}\${debugtitle}\""
543     rungrubby --debug ${ARGS}
544     rungrubby ${ARGS}
545     else
546     [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
547     fi
548    
549      shift   if [[ -n ${cfgGrub2} ]]
550     then
551     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
552     ARGS="--grub2 -c ${grub2Config} --update-kernel=${kernelImage} ${INITRD} \
553     ${kernargs:+--args=\"${kernargs}\"} \
554     ${removeargs:+--remove-args=\"${removeargs}\"} \
555     --title=\"${title}\${debugtitle}\""
556     rungrubby --debug ${ARGS}
557     rungrubby ${ARGS}
558     else
559     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
560     fi
561    
562     if [[ -n ${cfgGrub2Efi} ]]
563     then
564     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
565     ARGS="--grub2 -c ${grub2EfiConfig} --efi --update-kernel=${kernelImage} \
566     ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
567     ${removeargs:+--remove-args=\"${removeargs}\"} \
568     --title=\"${title}\${debugtitle}\""
569     rungrubby --debug ${ARGS}
570     rungrubby ${ARGS}
571     else
572     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
573     fi
574    
575     if [[ -n ${cfgLilo} ]]
576     then
577     [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
578     ARGS="--${liloFlag} --update-kernel=${kernelImage} ${INITRD} \
579     ${kernargs:+--args=\"${kernargs}\"} \
580     ${removeargs:+--remove-args=\"${removeargs}\"} \
581     --title=\"${title}\${debugtitle}\""
582     rungrubby --debug ${ARGS}
583     rungrubby ${ARGS}
584    
585     if [[ -n ${runLilo} ]]
586     then
587     [[ -n ${verbose} ]] && echo "running ${lilo}"
588     if [ ! -x ${lilo} ]
589     then
590     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
591     else
592     ${lilo} > /dev/null
593     fi
594     fi
595     else
596     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
597     fi
598    
599     if [[ -n ${cfguBoot} ]]
600     then
601     [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
602    
603     [[ -n ${verbose} ]] && echo "creating uImage-${version}"
604     mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \
605     -e ${ubootAddress} -n ${version} \
606     -d ${kernelImage} ${ubootDir}/uImage-${version}
607    
608     [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
609     mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
610     -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version}
611    
612     if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ]
613     then
614     cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage}
615     if [ $? -ne 0 ]
616     then
617     [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit
618     fi
619     cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd}
620     if [ $? -ne 0 ]
621     then
622     [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
623     fi
624     echo ${version} >> ${ubootDir}/${ubootKList}
625     [ -x /sbin/a-b-c ] && /sbin/a-b-c
626     else
627     [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
628     fi
629     else
630     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
631     fi
632    
633     if [[ -n ${cfgExtlinux} ]]
634     then
635     [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
636     ARGS="--extlinux -c ${extlinuxConfig} --update-kernel=${kernelImage} \
637     ${DEVTREE} ${DEVTREEDIR} ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
638     ${removeargs:+--remove-args=\"${removeargs}\"} \
639     --title=\"${title}\${debugtitle}\""
640     rungrubby --debug ${ARGS}
641     rungrubby ${ARGS}
642     else
643     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
644     fi
645    }
646    
647    makeinitrd()
648    {
649     if [[ -n ${dracut} ]]
650     then
651     tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
652     else
653     tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
654     fi
655     [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
656     ${tool}
657     rc=$?
658     if [ ${rc} != 0 ]
659     then
660     echo "mkinitrd failed" >&2
661     exit 1
662     fi
663    }
664    
665    rminitrd()
666    {
667     [[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}"
668     [ -f ${initrdfile} ] && rm -f ${initrdfile}
669    }
670    
671    doDepmod()
672    {
673     [[ -n ${verbose} ]] && echo "running depmod for ${version}"
674     depmod -ae -F /boot/System.map-${version} ${version}
675    }
676    
677    doRmmoddep()
678    {
679     [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
680     if [ -d /lib/modules/${version} ]
681     then
682     rm -f /lib/modules/${version}/modules.*.bin \
683     /lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep}
684     fi
685    }
686    
687    # kernel image for 2.4 is kernel
688    if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
689    then
690     if [[ ${kernelmajor} = 2.4 ]]
691     then
692     kernelName=kernel
693     fi
694    fi
695    
696    while [ $# -gt 0 ]
697    do
698     case $1 in
699     --mkinitrd)
700     initrd="make"
701     ;;
702    
703     --rminitrd)
704     initrd="remove"
705     ;;
706    
707     --devtree*)
708     if [[ $1 == --devtree\=* ]]
709     then
710     devtreefile="${1#--devtreefile=}"
711     else
712     devtreefile="$2"
713     shift
714     fi
715     ;;
716    
717     --devtreedir*)
718     if [[ $1 == --devtreedir\=* ]]
719     then
720     devtreedir=${1#--devtreedir=}
721     else
722     devtreedir=$2
723     shift
724     fi
725     ;;
726    
727     --dracut)
728     dracut=--dracut
729     ;;
730    
731     --host-only)
732     dracuthostonly=-H
733     ;;
734    
735     --initrdfile*)
736     if [[ $1 == --initrdfile\=* ]]
737     then
738     initrdfile=${1#--initrdfile=}
739     else
740     initrdfile=$2
741     shift
742     fi
743     ;;
744    
745     --kernel-args*)
746     if [[ $1 == --kernel-args\=* ]]
747     then
748     kernargs=${1#--kernel-args=}
749     else
750     kernargs=$2
751     shift
752     fi
753     ;;
754    
755     --remove-args*)
756     if [[ $1 == --remove-args\=* ]]
757     then
758     removeargs=${1#--remove-args=}
759     else
760     removeargs=$2
761     shift
762     fi
763     ;;
764    
765     --banner*)
766     if [[ $1 == --banner\=* ]]
767     then
768     banner=${1#--banner=}
769     else
770     banner=$2
771     shift
772     fi
773     ;;
774    
775     --multiboot*)
776     if [[ $1 == --multiboot\=* ]]
777     then
778     mbkernel=${1#--multiboot=}
779     else
780     # can't really support having an optional second arg here
781     # sorry!
782     mbkernel="/boot/xen.gz"
783     fi
784     ;;
785    
786     --mbargs*)
787     if [[ $1 == --mbargs\=* ]]
788     then
789     mbargs=${1#--mbargs=}
790     else
791     mbargs="$2"
792     shift
793     fi
794     ;;
795    
796     --depmod)
797     moddep="make"
798     ;;
799    
800     --rmmoddep)
801     moddep="remove"
802     ;;
803    
804     --make-default)
805     makedefault="--make-default"
806     ;;
807    
808     --package*)
809     if [[ $1 == --package\=* ]]
810     then
811     package=${1#--package=}
812     else
813     package=$2
814     shift
815     fi
816     ;;
817    
818     --add-dracut-args)
819     adddracutargs=--add-dracut-args
820     ;;
821    
822     --add-plymouth-initrd)
823     addplymouthinitrd=--add-plymouth-initrd
824     ;;
825    
826     --kernel-image*)
827     if [[ $1 == --kernel-image\=* ]]
828     then
829     kernelImage=${1#--kernel-image=}
830     else
831     kernelImage="$2"
832     shift
833     fi
834     if ! [[ -f ${kernelImage} ]]
835     then
836     echo "Can't find kernel image '${kernelImage}'" >&2
837     usage
838     exit 1
839     fi
840     ;;
841    
842     --kernel-name*)
843     if [[ $1 == --kernel-name\=* ]]
844     then
845     kernelName=${1#--kernel-name=}
846     else
847     kernelName="$2"
848     shift
849     fi
850     ;;
851    
852     -v)
853     verbose=-v
854     ;;
855    
856     *)
857     if [[ -z ${mode} ]]
858     then
859     mode=$1
860     elif [[ -z ${version} ]]
861     then
862     version=$1
863     else
864     usage
865     fi
866     ;;
867     esac
868    
869     shift
870  done  done
871    
872  # make sure the mode is valid  # make sure the mode is valid
873  if [ "$mode" != "--install" -a "$mode" != "--remove" ] ; then  if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]]
874      usage  then
875     usage
876  fi  fi
877    
878  if [ -z "$version" ]; then  if [[ -z ${version} ]]
879      usage  then
880     usage
881  fi  fi
882    
883  if [ "$mode" != "--install" -a "$makedefault" ]; then  if [ "${mode}" != "--install" -a "${makedefault}" ]
884      usage  then
885     usage
886  fi  fi
887    
888  # make sure that /dev/loop exist  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
 [[ ! -e /dev/loop ]] && modprobe loop  
889    
890  kernelmajor=`echo $kernel | cut -d . -f 1,2`  [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"
891    
892  # kernel image for 2.4 is vmlinux  # set the initrd file based on arch; ia64 is the only currently known oddball
893  if [ $ARCH = 'ppc64' -o $ARCH = 'ppc' ]; then  if [[ -z ${initrdfile} ]]
894    if [ "$kernelmajor" == "2.4" ]; then  then
895        kernelName=vmlinux   INITRD_NAME_PREFIX="initrd"
896    fi   if [[ -n ${dracut} ]]
897     then
898     INITRD_NAME_PREFIX="initramfs"
899     fi
900    
901     if [[ $(uname -m) = ia64 ]]
902     then
903     initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img"
904     else
905     initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img"
906     fi
907  fi  fi
908    [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
909    
910    if [[ ${ARCH} =~ armv[5|7].*l ]]
911    then
912     if [[ -z ${SHIPSDTB} ]] || [[ ${SHIPSDTB} != yes ]]
913     then
914     if [[ -n ${dtbfile} ]] && [ -f ${bootPrefix}/dtb-${version}/${dtbfile} ]
915     then
916     devtreefile="${bootPrefix}/dtb-${version}/${dtbfile}"
917     [[ -n ${verbose} ]] && echo "devtreefile is ${devtreefile}"
918     elif [ -d ${bootPrefix}/dtb-${version}/ ]
919     then
920     devtreedir="${bootPrefix}/dtb-${version}/"
921     [[ -n ${verbose} ]] && echo "devtreedir is ${devtreedir}"
922     fi
923     fi
924    fi
925    [[ -n ${verbose} ]] && echo "devtreedir is ${devtreedir}"
926    
927  # set the initrd file based on arch; ia64 is the only currently known oddball  # add dracut i18n, keyboard and plymouth kernel args if requested
928  if [ -z "$initrdfile" ]; then  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
929      if [ `uname -m` = "ia64" ]; then  then
930   initrdfile="/boot/efi/EFI/redhat/initrd-$version.img"   if [ -r /etc/vconsole.conf ]
931      else   then
932   initrdfile="/boot/initrd-$version.img"   . /etc/vconsole.conf
933      fi  
934     for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE
935     do
936     val=$(eval echo \$$i)
937     [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}"
938     done
939     else
940     if [ -r /etc/conf.d/consolefont ]
941     then
942     . /etc/conf.d/consolefont
943    
944     if [[ -n ${CONSOLEFONT} ]]
945     then
946     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
947     fi
948     fi
949    
950     if  [ -r /etc/conf.d/keymap ]
951     then
952     . /etc/conf.d/keymap
953    
954     if [[ -n ${KEYMAP} ]]
955     then
956     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
957     fi
958     fi
959     fi
960    
961     if [ -r /etc/locale.conf ]
962     then
963     . /etc/locale.conf
964    
965     if [[ -n ${LANG} ]]
966     then
967     kernargs="${kernargs} LANG=${LANG}"
968     fi
969     fi
970  fi  fi
 [ -n "$verbose" ] && echo "initrdfile is $initrdfile"  
971    
972  # 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
973  if [ "$mode" == "--install" -a "$UPDATEDEFAULT" == "yes" -a -n "$package" -a -n "$DEFAULTKERNEL" -a "$package" == "$DEFAULTKERNEL" ]; then  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && [[ -n ${DEFAULTKERNEL} ]]
974      makedefault="--make-default"  then
975      [ -n "$verbose" ] && echo "making it the default based on config"   if [[ ${package} = ${DEFAULTKERNEL} ]] || [[ ${package}-core = ${DEFAULTKERNEL} ]]
976     then
977     makedefault="--make-default"
978     [[ -n ${verbose} ]] && echo "making it the default based on config"
979     fi
980  fi  fi
981    
982  if [ "$moddep" == "make" ]; then  if [[ ${moddep} = make ]]
983      doDepmod  then
984  elif [ "$moddep" == "remove" ]; then   doDepmod
985      doRmmoddep  elif [[ ${moddep} = remove ]]
986    then
987     doRmmoddep
988  fi  fi
989    
990  if [ "$initrd" == "make" ]; then  if [[ ${initrd} = make ]]
991      mkinitrd  then
992  elif [ "$initrd" == "remove" ]; then   makeinitrd
993      rminitrd  elif [[ ${initrd} = remove ]]
994    then
995     rminitrd
996  fi  fi
997    
998  if [ ! -x $grubby ] ; then  if [ ! -x ${grubby} ]
999      [ -n "$verbose" ] && echo "$grubby does not exist"  then
1000      exit 0   [[ -n ${verbose} ]] && echo "${grubby} does not exist"
1001     exit 0
1002  fi  fi
1003    
1004    [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
1005    [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
1006    [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
1007    [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
1008    [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
1009    
1010    # if we have a U-Boot directory, but no boot script, check if the directory
1011    # is mounted.  If not, mount it, and then check if a boot script exists.
1012    if [[ -n ${ubootDir} ]]
1013    then
1014     if [ -f ${ubootScript} ]
1015     then
1016     cfguBoot=1
1017     else
1018     mountEntry=$(mount | grep ${ubootDir})
1019     if [[ -z ${mountEntry} ]]
1020     then
1021     mount ${ubootDevice} ${ubootDir}
1022     mounted=1
1023     fi
1024     [ -f ${ubootScript} ] && cfguBoot=1
1025     fi
1026    fi
1027    
1028  [ -n "$grubConfig" ] && [ -f "$grubConfig" ] && cfgGrub=1;  # if we're using U-Boot, check if the default load address should change
1029  [ -n "$liloConfig" ] && [ -f "$liloConfig" ] && cfgLilo=1;  if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]]
1030    then
1031     [[ ${version}  =~ .([^.]*)$ ]]
1032     platform=${BASH_REMATCH[1]}
1033     # A few platforms use an alternate kernel load address
1034     if [[ ${platform} = omap ]]
1035     then
1036     ubootAddress=0x80008000
1037     elif [[ ${platform} = imx ]]
1038     then
1039     ubootAddress=0x90008000
1040     fi
1041    fi
1042    
1043  # 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
1044  # is lilo to determine if it should be run  # is lilo to determine if it should be run
1045  if [ -n "$cfgLilo" -a -n "$isx86" ]; then  if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]
1046      runLilo=$($grubby --bootloader-probe | grep lilo)  then
1047     runLilo=$(${grubby} --bootloader-probe | grep lilo)
1048  fi  fi
1049    
1050  if [ "$mode" == "--install" ]; then  if [[ ${mode} = --install ]]
1051      install  then
1052  elif [ "$mode" == "--remove" ]; then   install
1053      remove  elif [[ ${mode} = --remove ]]
1054    then
1055     remove
1056    elif [[ ${mode} = --update ]]
1057    then
1058     update
1059  fi  fi
1060    
1061    # if we mounted the U-Boot directory, unmount it.
1062    [[ -n ${mounted} ]] && umount ${ubootDir}
1063    
1064  exit 0  exit 0

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