Magellan Linux

Annotation of /trunk/grubby/new-kernel-pkg

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1697 - (hide annotations) (download)
Sat Feb 18 00:15:09 2012 UTC (12 years, 8 months ago) by niro
File size: 20220 byte(s)
Update grub2 support to new-kernel-pkg

This uses grubby for grub2 on efi and non-efi machines.


1 niro 532 #!/bin/bash
2 niro 924 # $Id$
3 niro 532 #
4 niro 923 # new-kernel-pkg
5 niro 532 # Invoked upon installation or removal of a kernel package, the following
6     # tasks are/can be done here:
7     # creation/removal of initrd
8     # run of depmod/removal of depmod generated files
9     # addition/removal of kernel images from grub/lilo configuration (via grubby)
10     #
11 niro 923 # Copyright 2002-2008 Red Hat, Inc. All rights reserved.
12 niro 532 # modified for Magellan-Linux by Niels Rogalla <niro@magellan-linux.de>
13     #
14 niro 923 # 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 niro 532
28     PATH=/sbin:/bin:$PATH
29    
30     lilo=/sbin/lilo
31    
32     # some defaults that are sane for most arches
33     kernelName=kernel
34    
35 niro 924 if [ -x ./grubby ]
36     then
37     grubby=./grubby
38 niro 532 else
39 niro 924 grubby=/sbin/grubby
40 niro 532 fi
41    
42 niro 925 [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby
43 niro 1691 [ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot
44 niro 532
45 niro 1697 cfgGrub2=""
46     cfgGrub2Efi=""
47 niro 532 cfgGrub=""
48     cfgLilo=""
49 niro 1691 cfguBoot=""
50 niro 532 runLilo=""
51     grubConfig=""
52    
53     ARCH=$(uname -m)
54    
55 niro 924 if [[ ${ARCH} = ia64 ]]
56     then
57     liloConfig=/boot/efi/EFI/redhat/elilo.conf
58     bootPrefix=/boot/efi/EFI/redhat
59     liloFlag=elilo
60     isx86=""
61     elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
62     then
63     liloConfig=/etc/yaboot.conf
64     bootPrefix=/boot
65     lilo=/sbin/ybin
66     liloFlag=yaboot
67     runLilo="yes"
68     isx86=""
69     elif [[ ${ARCH} = sparc ]] || [[ ${ARCH} = sparc64 ]]
70     then
71     liloConfig=/etc/silo.conf
72     bootPrefix=/boot
73     liloFlag=silo
74     lilo=/sbin/silo
75     isx86=""
76     elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
77     then
78     liloConfig=/etc/zipl.conf
79     bootPrefix=/boot
80     liloFlag=zipl
81     lilo=/sbin/zipl
82     runLilo="yes"
83     isx86=""
84 niro 1691 elif [[ ${ARCH} = armv7l ]]
85     then
86     liloConfig=""
87     bootPrefix=/boot
88     ubootDir=${UBOOT_DIR:-"/boot/uboot"}
89     ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
90     ubootKList=${UBOOT_KLIST:-"klist.txt"}
91     ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
92     ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
93     ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
94     mounted=""
95     liloFlag=""
96     isx86=""
97 niro 532 else
98 niro 924 # this leaves i?86 and x86_64
99     liloConfig=/etc/lilo.conf
100     grubConfig=/boot/grub/grub.conf
101 niro 1697 grub2Config=/boot/grub/grub.cfg
102     grub2EfiConfig=/boot/grub/grub-efi.cfg
103 niro 924 bootPrefix=/boot
104     liloFlag=lilo
105     isx86="yes"
106 niro 532 fi
107    
108     mode=""
109     version=""
110     initrd=""
111 niro 1334 dracut=""
112     dracuthostonly=""
113 niro 532 initrdfile=""
114     moddep=""
115     verbose=""
116     makedefault=""
117     package=""
118     mbkernel=""
119     mbargs=""
120 niro 1334 adddracutargs=""
121     addplymouthinitrd=""
122 niro 532
123 niro 924 usage()
124     {
125 niro 1334 echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
126 niro 924 echo " [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
127 niro 1305 echo " [--kernel-args=<args>] [--remove-args=<args>]" >&2
128 niro 924 echo " [--banner=<banner>] [--multiboot=multiboot]" >&2
129 niro 1334 echo " [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
130     echo " [--add-plymouth-initrd]" >&2
131     echo " [--host-only]" >&2
132 niro 924 echo " <--install | --remove | --update> <kernel-version>" >&2
133     echo " (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
134     exit 1
135 niro 532 }
136    
137 niro 924 install()
138     {
139     # XXX kernel should be able to be specified also (or work right on ia64)
140     if [ ! -f ${bootPrefix}/${kernelName}-${version} ]
141     then
142     [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
143     return
144     fi
145 niro 923
146 niro 924 INITRD=""
147     if [ -f ${initrdfile} ]
148     then
149     [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
150     INITRD="--initrd ${initrdfile}"
151 niro 1334
152     if [[ -n ${addplymouthinitrd} ]]
153     then
154     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
155     fi
156 niro 924 fi
157 niro 532
158 niro 924 # FIXME: is this a good heuristic to find out if we're on iSeries?
159     if [ -d /proc/iSeries ]
160     then
161     [[ -n ${verbose} ]] && echo "On an iSeries, just making img file"
162     if [[ -z ${initrdfile} ]]
163     then
164     [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
165     /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version}
166     else
167     /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version}
168     /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null
169     rm ${bootPrefix}/vmlinux.sm-${version}
170     fi
171     return
172 niro 532 fi
173    
174 niro 924 # get the root filesystem to use
175     rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)
176 niro 532
177 niro 924 if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
178     then
179     [[ -n ${verbose} ]] && echo "multiboot specified, not updating lilo.conf"
180     cfgLilo=""
181     fi
182 niro 532
183 niro 924 if [[ -n ${cfgGrub} ]]
184     then
185     [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
186 niro 532
187 niro 924 if [[ -n ${banner} ]]
188     then
189     title="${banner} (${version})"
190     elif [ -f /etc/mageversion ]
191     then
192     title="Magellan Linux $(< /etc/mageversion) (${version})"
193     else
194     title="Magellan Linux (${version})"
195     fi
196 niro 1697 ${grubby} --grub --add-kernel=${bootPrefix}/${kernelName}-${version} \
197 niro 924 ${INITRD} --copy-default ${makedefault} --title "${title}" \
198     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
199     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
200 niro 532 else
201 niro 1697 [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
202 niro 532 fi
203 niro 1697 if [[ -n ${cfgGrub2} ]]
204     then
205     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
206 niro 532
207 niro 1697 if [[ -n ${banner} ]]
208     then
209     title="${banner} (${version})"
210     elif [ -f /etc/mageversion ]
211     then
212     title="Magellan Linux $(< /etc/mageversion) (${version})"
213     else
214     title="Magellan Linux (${version})"
215     fi
216     ${grubby} --grub2 -c ${grub2Cfg} \
217     --add-kernel=${bootPrefix}/${kernelName}-${version} \
218     ${INITRD} --copy-default ${makedefault} --title "${title}" \
219     ${mbkernel:+--add-multiboot="${mbkernel}"} \
220     ${mbargs:+--mbargs="${mbargs}"} \
221     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
222     else
223     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
224     fi
225     if [[ -n ${cfgGrub2Efi} ]]
226     then
227     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
228    
229     if [[ -n ${banner} ]]
230     then
231     title="${banner} (${version})"
232     elif [ -f /etc/mageversion ]
233     then
234     title="Magellan Linux $(< /etc/mageversion) (${version})"
235     else
236     title="Magellan Linux (${version})"
237     fi
238     ${grubby} --grub2 -c ${grub2EfiCfg} \
239     --add-kernel=${bootPrefix}/${kernelName}-${version} \
240     ${INITRD} --copy-default ${makedefault} --title "${title}" \
241     ${mbkernel:+--add-multiboot="${mbkernel}"} \
242     ${mbargs:+--mbargs="${mbargs}"} \
243     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
244     else
245     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"
246     fi
247    
248 niro 924 if [[ -n ${cfgLilo} ]]
249     then
250     [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
251 niro 532
252 niro 924 ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \
253     --copy-default ${makedefault} --title ${version} \
254     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
255     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \
256     --${liloFlag}
257 niro 532
258 niro 924 if [[ -n ${runLilo} ]]
259     then
260     [[ -n ${verbose} ]] && echo "running ${lilo}"
261 niro 1305 if [ ! -x ${lilo} ]
262 niro 924 then
263     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
264     else
265     ${lilo} > /dev/null
266     fi
267     fi
268     else
269     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
270 niro 532 fi
271     }
272    
273 niro 924 remove()
274     {
275     # FIXME: is this a good heuristic to find out if we're on iSeries?
276     if [ -d /proc/iSeries ]
277     then
278     [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
279     rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null
280     return
281     fi
282 niro 532
283 niro 924 if [[ -n ${cfgGrub} ]]
284     then
285     [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
286 niro 1697 ${grubby} --grub --remove-kernel=${bootPrefix}/${kernelName}-${version}
287 niro 924 else
288 niro 1697 [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
289 niro 924 fi
290 niro 1697 if [[ -n ${cfgGrub2} ]]
291     then
292     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
293     ${grubby} --grub2 -c ${grub2Config} \
294     --remove-kernel=${bootPrefix}/${kernelName}-${version}
295     else
296     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
297     fi
298     if [[ -n ${cfgGrub2Efi} ]]
299     then
300     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
301     ${grubby} --grub2 -c ${grub2EfiConfig} \
302     --remove-kernel=${bootPrefix}/${kernelName}-${version}
303     else
304     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
305     fi
306 niro 532
307 niro 924 if [[ -n ${cfgLilo} ]]
308     then
309     [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
310 niro 1305 ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}
311 niro 532
312 niro 924 if [[ -n ${runLilo} ]]
313     then
314     [[ -n ${verbose} ]] && echo "running ${lilo}"
315     if [ ! -x ${lilo} ]
316     then
317     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
318     else
319     ${lilo} > /dev/null
320     fi
321     fi
322     else
323     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
324 niro 532 fi
325 niro 1691
326     if [[ -n ${cfguBoot} ]]
327     then
328     [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..."
329    
330     if [ -f ${ubootDir}/${ubootKList} ]
331     then
332     tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
333     curversion=$(tail -n1 ${ubootDir}/${ubootKList})
334     sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList}
335     newversion=$(tail -n1 ${tmpKList})
336     if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
337     then
338     if [[ ${curversion} != ${newversion} ]]
339     then
340     cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage}
341     if [ $? -ne 0 ]
342     then
343     [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit
344     fi
345     cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd}
346     if [ $? -ne 0 ]
347     then
348     [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit
349     fi
350     fi
351    
352     [[ -n ${verbose} ]] && echo "removing uImage-${version}"
353     if [ -f ${ubootDir}/uImage-${version} ]
354     then
355     rm -f ${ubootDir}/uImage-${version}
356     else
357     [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!"
358     fi
359    
360     [[ -n ${verbose} ]] && echo "removing uInitrd-${version}"
361     if [ -f ${ubootDir}/uInitrd-${version} ]
362     then
363     rm -f ${ubootDir}/uInitrd-${version}
364     else
365     [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!"
366     fi
367    
368     mv ${tmpKList} ${ubootDir}/${ubootKList}
369     else
370     [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
371     [ -f ${tmpKList} ] && rm -f ${tmpKList}
372     fi
373     else
374     [[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!"
375     fi
376     else
377     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
378     fi
379 niro 532 }
380    
381 niro 924 update()
382     {
383 niro 1305 if [ ! -f ${bootPrefix}/${kernelName}-${version} ]
384     then
385     [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
386     return
387     fi
388    
389     INITRD=""
390     if [ -f ${initrdfile} ]
391     then
392     [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
393     INITRD="--initrd ${initrdfile}"
394 niro 1334
395     if [[ -n ${addplymouthinitrd} ]]
396     then
397     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
398     fi
399 niro 1305 fi
400    
401 niro 924 if [[ -n ${cfgGrub} ]]
402     then
403     [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
404     ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \
405 niro 1305 ${INITRD} \
406 niro 924 ${kernargs:+--args="${kernargs}"} \
407     ${removeargs:+--remove-args="${removeargs}"}
408     else
409     [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
410     fi
411 niro 923
412 niro 1697 if [[ -n ${cfgGrub2} ]]
413     then
414     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
415     ${grubby} --grub2 -c ${grub2Config} \
416     --update-kernel=${bootPrefix}/${kernelName}-${version} \
417     ${INITRD} \
418     ${kernargs:+--args="${kernargs}"} \
419     ${removeargs:+--remove-args="${removeargs}"}
420     else
421     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
422     fi
423    
424     if [[ -n ${cfgGrub2Efi} ]]
425     then
426     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
427     ${grubby} --grub2 -c ${grub2EfiConfig} \
428     --update-kernel=${bootPrefix}/${kernelName}-${version} \
429     ${INITRD} \
430     ${kernargs:+--args="${kernargs}"} \
431     ${removeargs:+--remove-args="${removeargs}"}
432     else
433     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
434     fi
435    
436 niro 924 if [[ -n ${cfgLilo} ]]
437     then
438     [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
439     ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \
440 niro 1305 ${INITRD} \
441 niro 924 ${kernargs:+--args="${kernargs}"} \
442     ${removeargs:+--remove-args="${removeargs}"} \
443     --${liloFlag}
444 niro 923
445 niro 924 if [[ -n ${runLilo} ]]
446     then
447     [[ -n ${verbose} ]] && echo "running ${lilo}"
448     if [ ! -x ${lilo} ]
449     then
450     [[ -n ${verbose} ]] && echo "${lilo} does not exist"
451     else
452     ${lilo} > /dev/null
453     fi
454     fi
455     else
456     [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
457 niro 923 fi
458 niro 1691
459     if [[ -n ${cfguBoot} ]]
460     then
461     [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
462    
463     [[ -n ${verbose} ]] && echo "creating uImage-${version}"
464     mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \
465     -n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}
466    
467     [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
468     mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
469     -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version}
470    
471     if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ]
472     then
473     cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage}
474     if [ $? -ne 0 ]
475     then
476     [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit
477     fi
478     cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd}
479     if [ $? -ne 0 ]
480     then
481     [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
482     fi
483     echo ${version} >> ${ubootDir}/${ubootKList}
484     else
485     [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
486     fi
487     else
488     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
489     fi
490 niro 923 }
491    
492 niro 924 mkinitrd()
493     {
494 niro 1334 if [[ -n ${dracut} ]]
495     then
496     tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}"
497     else
498     tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}"
499     fi
500 niro 924 [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
501 niro 1334 ${tool}
502 niro 924 rc=$?
503     if [ ${rc} != 0 ]
504     then
505     echo "mkinitrd failed" >&2
506     exit 1
507     fi
508 niro 532 }
509    
510 niro 924 rminitrd()
511     {
512     [[ -n ${verbose} ]] && echo "removing initrd ${initrdfile}"
513     [ -f ${initrdfile} ] && rm -f ${initrdfile}
514 niro 532 }
515    
516 niro 924 doDepmod()
517     {
518     [[ -n ${verbose} ]] && echo "running depmod for ${version}"
519     depmod -ae -F /boot/System.map-${version} ${version}
520 niro 532 }
521    
522 niro 924 doRmmoddep()
523     {
524     [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
525     [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*
526 niro 532 }
527    
528    
529 niro 924 while [ $# -gt 0 ]
530     do
531     case $1 in
532     --mkinitrd)
533     initrd="make"
534     ;;
535 niro 532
536 niro 924 --rminitrd)
537     initrd="remove"
538     ;;
539 niro 532
540 niro 1334 --dracut)
541     dracut=--dracut
542     ;;
543    
544     --host-only)
545     dracuthostonly=-H
546     ;;
547    
548 niro 924 --initrdfile*)
549     if echo $1 | grep '=' >/dev/null
550     then
551     initrdfile=$(echo $1 | sed 's/^--initrdfile=//')
552     else
553     initrdfile=$2
554     shift
555     fi
556     ;;
557 niro 532
558 niro 924 --kernel-args*)
559     if echo $1 | grep '=' >/dev/null
560     then
561     kernargs=$(echo $1 | sed 's/^--kernel-args=//')
562     else
563     kernargs=$2
564     shift
565     fi
566     ;;
567 niro 532
568 niro 924 --remove-args*)
569     if echo $1 | grep '=' >/dev/null
570     then
571 niro 1305 removeargs=$(echo $1 | sed 's/^--remove-args=//')
572 niro 924 else
573     removeargs=$2
574     shift
575     fi
576     ;;
577 niro 923
578 niro 924 --banner*)
579     if echo $1 | grep '=' >/dev/null
580     then
581     banner=$(echo $1 | sed 's/^--banner=//')
582     else
583     banner=$2
584     shift
585     fi
586     ;;
587 niro 532
588 niro 924 --multiboot*)
589     if echo $1 |grep '=' >/dev/null
590     then
591     mbkernel=$(echo $1 | sed 's/^--multiboot=//')
592     else
593     # can't really support having an optional second arg here
594     # sorry!
595     mbkernel="/boot/xen.gz"
596     fi
597     ;;
598 niro 532
599 niro 924 --mbargs*)
600     if echo $1 |grep '=' >/dev/null
601     then
602     mbargs=$(echo $1 | sed 's/^--mbargs=//')
603     else
604     mbargs="$2"
605     shift
606     fi
607     ;;
608 niro 532
609 niro 924 --depmod)
610     moddep="make"
611     ;;
612 niro 532
613 niro 924 --rmmoddep)
614     moddep="remove"
615     ;;
616 niro 532
617 niro 924 --make-default)
618     makedefault="--make-default"
619     ;;
620 niro 532
621 niro 924 --package)
622     if echo $1 | grep '=' >/dev/null
623     then
624     package=$(echo $1 | sed 's/^--package=//')
625     else
626     package=$2
627     shift
628     fi
629     ;;
630 niro 532
631 niro 1334 --add-dracut-args)
632     adddracutargs=--add-dracut-args
633     ;;
634    
635     --add-plymouth-initrd)
636     addplymouthinitrd=--add-plymouth-initrd
637     ;;
638    
639 niro 924 -v)
640     verbose=-v
641     ;;
642 niro 532
643 niro 924 *)
644     if [[ -z ${mode} ]]
645     then
646     mode=$1
647     elif [[ -z ${version} ]]
648     then
649     version=$1
650     else
651     usage
652     fi
653     ;;
654     esac
655 niro 532
656 niro 924 shift
657 niro 532 done
658    
659     # make sure the mode is valid
660 niro 924 if [[ ${mode} != --install ]] && [[ ${mode} != --remove ]] && [[ ${mode} != --update ]]
661     then
662     usage
663 niro 532 fi
664    
665 niro 924 if [[ -z ${version} ]]
666     then
667     usage
668 niro 532 fi
669    
670 niro 924 if [ "${mode}" != "--install" -a "${makedefault}" ]
671     then
672     usage
673 niro 532 fi
674    
675 niro 924 kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
676 niro 532
677 niro 1305 # kernel image for 2.4 is kernel
678 niro 924 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
679     then
680     if [[ ${kernelmajor} = 2.4 ]]
681     then
682     kernelName=kernel
683     fi
684 niro 532 fi
685    
686     # set the initrd file based on arch; ia64 is the only currently known oddball
687 niro 924 if [[ -z ${initrdfile} ]]
688     then
689     INITRD_NAME_PREFIX="initrd"
690 niro 1334 if [[ -n ${dracut} ]]
691     then
692     INITRD_NAME_PREFIX="initramfs"
693     fi
694 niro 923
695 niro 924 if [[ $(uname -m) = ia64 ]]
696     then
697     initrdfile="/boot/efi/EFI/redhat/${INITRD_NAME_PREFIX}-${version}.img"
698     else
699     initrdfile="/boot/${INITRD_NAME_PREFIX}-${version}.img"
700     fi
701 niro 532 fi
702 niro 924 [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
703 niro 532
704 niro 1334 # add dracut i18n, keyboard and plymouth kernel args if requested
705     if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
706     then
707     [ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap
708     [ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont
709    
710     if [[ -n ${KEYMAP} ]]
711     then
712     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
713     fi
714    
715     if [[ -n ${CONSOLEFONT} ]]
716     then
717     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
718     fi
719     fi
720    
721 niro 532 # set this as the default if we have the package and it matches
722 niro 924 if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&
723     [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]
724     then
725     makedefault="--make-default"
726     [[ -n ${verbose} ]] && echo "making it the default based on config"
727 niro 532 fi
728    
729 niro 924 if [[ ${moddep} = make ]]
730     then
731     doDepmod
732     elif [[ ${moddep} = remove ]]
733     then
734     doRmmoddep
735 niro 532 fi
736    
737 niro 924 if [[ ${initrd} = make ]]
738     then
739     mkinitrd
740     elif [[ ${initrd} = remove ]]
741     then
742     rminitrd
743 niro 532 fi
744    
745 niro 924 if [ ! -x ${grubby} ]
746     then
747     [[ -n ${verbose} ]] && echo "${grubby} does not exist"
748     exit 0
749 niro 532 fi
750    
751 niro 924 [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
752 niro 1697 [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
753     [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
754 niro 924 [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
755 niro 532
756 niro 1691 # if we have a uBoot directory, check if it is mounted.
757     # if not, mount it. Then check if a boot script exists.
758     if [[ -n ${ubootDir} ]]
759     then
760     mountEntry=$(mount | grep ${ubootDir})
761     if [[ -z ${mountEntry} ]]
762     then
763     mount ${ubootDevice} ${ubootDir}
764     mounted=1
765     fi
766     [ -f ${ubootScript} ] && cfguBoot=1
767     fi
768    
769 niro 532 # if we have a lilo config on an x86 box, see if the default boot loader
770     # is lilo to determine if it should be run
771 niro 924 if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]
772     then
773     runLilo=$(${grubby} --bootloader-probe | grep lilo)
774 niro 532 fi
775    
776 niro 924 if [[ ${mode} = --install ]]
777     then
778     install
779     elif [[ ${mode} = --remove ]]
780     then
781     remove
782     elif [[ ${mode} = --update ]]
783     then
784     update
785 niro 532 fi
786    
787     exit 0

Properties

Name Value
svn:executable *