Magellan Linux

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

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

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

Legend:
Removed from v.923  
changed lines
  Added in v.2965