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